简体   繁体   English

使用PowerShell获取操作系统信息,将Buildnumber更改为String

[英]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 . 该脚本将所有文件输出到一个csv中,以后我将替换所有内部版本号,例如:我将9600替换为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. 我可以编写一个脚本来替换.csv中的9600,但是我需要一个直接替换内部版本号的解决方案。

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. 另外,我需要更改值以将其写入.csv文件。

I have PowerShell V. 4.0 我有PowerShell V.4.0

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 *

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM