RayofCommand
RayofCommand

Reputation: 4244

Get Operating System info using PowerShell, change Buildnumber to String

Currently I am querying my Servers for their operating system like this(it's just a part of my full script):

Get-WmiObject -class Win32_OperatingSystem | % { $_.Buildnumber }

The script out-files everything to a csv where I later on replace all Buildnumbers, for example: I replace 9600 with Windows Server 2012 R2. I can write a script which replaces the 9600 in a .csv, but I need a solution which replaces the buildnumber directly.

I am thinking of something like that:

If Buildnumber = 9600 -replace "9600", "Windows Server 2012"

So far I had no luck. Also I need to changed value to be written to my .csv file.

I have PowerShell V. 4.0

Upvotes: 1

Views: 501

Answers (1)

sodawillow
sodawillow

Reputation: 13176

Get-WmiObject -class Win32_OperatingSystem | Select Caption

holds what you want.

I know it is there from previous questions, but you can see it all like this :

Get-WmiObject -class Win32_OperatingSystem | fl *

Upvotes: 2

Related Questions