2017-10-13 108 views
0

我需要从WMI中检索操作系统名称。有没有办法检索它unlocalized? 目前,我通过美国的语言环境,但检索到的操作系统名称仍在俄语区域设置中。WMI - 获取未本地化的操作系统名称

我用下面的:

(Get-WmiObject -Class Win32_OperatingSystem -Locale ms_409).Name 

任何想法?

+1

为什么它必须来自WMI? – Clijsters

回答

1

不幸的是,在包含操作系统名称的WMI中没有语言通用属性。 然而,通过这段代码,您可以获得所需的信息:

$WMIOS = (Get-WmiObject -Class Win32_OperatingSystem) 
$SytemType = [String]::Empty 

$OS = [String]::Empty 
switch ($WMIOS.ProductType) 
{ 
    '1' 
    { 
     switch ($WMIOS.Version) 
     { 
     {$_ -like "6.0*"} {$OS = "Windows Vista";break} 
     {$_ -like "6.1*"} {$OS = "Windows 7";break} 
     {$_ -like "6.2*"} {$OS = "Windows 8";break} 
     {$_ -like "6.3*"} {$OS = "Windows 8.1";break} 
     {$_ -like "10*"} {$OS = "Windows 10";break} 
     Default {Return} 
     } 
    } 
    {$_ -in '2','3'} 
    { 
     switch ($WMIOS.Version) 
     { 
      {$_ -like "6.0*"} {$OS = "Windows Server 2008";break} 
      {$_ -like "6.1*"} {$OS = "Windows Server 2008 R2";break} 
      {$_ -like "6.2*"} {$OS = "Windows Server 2012";break} 
      {$_ -like "6.3*"} {$OS = "Windows Server 2012 R2 ";break} 
      {$_ -like "10*"} {$OS = "Windows Server 2016";break} 
      Default {Return} 
      } 
     } 
    } 
} 

$ProductSKU = [String]::Empty 
switch ($WMIOS.OperatingSystemSKU) 
{ 
    '1' {$ProductSKU = "Ultimate";break} 
    '2' {$ProductSKU = "Home Basic";break} 
    '3' {$ProductSKU = "Home Premium";break} 
    '4' {$ProductSKU = "Enterprise";break} 
    '6' {$ProductSKU = "Professional";break} 
    '7' {$ProductSKU = "Standard";break} 
    '8' {$ProductSKU = "Datacenter";break} 
    '9' {$ProductSKU = "Small Business";break} 
    '10' {$ProductSKU = "Enterprise";break} 
    '11' {$ProductSKU = "Starter";break} 
    '12' {$ProductSKU = "Datacenter CORE";break} 
    '13' {$ProductSKU = "Standard CORE";break} 
    '14' {$ProductSKU = "Enterprise CORE";break} 
    '17' {$ProductSKU = "WEB Server";break} 
    '19' {$ProductSKU = "Home Server";break} 
    '20' {$ProductSKU = "Storage Express Server";break} 
    '21' {$ProductSKU = "Storage Standard Server";break} 
    '22' {$ProductSKU = "Storage Workgroup Server";break} 
    '23' {$ProductSKU = "Storage Enterprise Server";break} 
    '24' {$ProductSKU = "Product Server For Small Business";break} 
    '25' {$ProductSKU = "Product Small Business Server Premium";break} 
    '27' {$ProductSKU = "Product Enterprise N";break} 
    '28' {$ProductSKU = "Product Ultimate N";break} 
    '29' {$ProductSKU = "Web Server CORE";break} 
    '36' {$ProductSKU = "Standard Server V";break} 
    '37' {$ProductSKU = "Datacenter Server V";break} 
    '38' {$ProductSKU = "Enterprise Server Core V";break} 
    '39' {$ProductSKU = "Datacenter Server Core V";break} 
    '40' {$ProductSKU = "Standard Server Core V";break} 
    '41' {$ProductSKU = "Enterprise Server Core V";break} 
    '42' {$ProductSKU = "Hyper-V";break} 
    '43' {$ProductSKU = "Storage Express Server Core";break} 
    '44' {$ProductSKU = "Storage Standard Server Core";break} 
    '45' {$ProductSKU = "Storage Workgroup Server Core";break} 
    '46' {$ProductSKU = "Storage Enterprise Server Core";break} 
    '50' {$ProductSKU = "SB Solution Server";break} 
    '63' {$ProductSKU = "Small Business Server Premium Core";break} 
    '64' {$ProductSKU = "Cluster Server V";break} 
    '97' {$ProductSKU = "Product Core ARM";break} 
    '101' {$ProductSKU = "Product Core";break} 
    '103' {$ProductSKU = "Professional WMC";break} 
    '104' {$ProductSKU = "Product Mobile Core";break} 
    '123' {$ProductSKU = "Product IOTUAP";break} 
    '143' {$ProductSKU = "Product Datacenter Nano Server";break} 
    '144' {$ProductSKU = "Product Standard Nano Server";break} 
    '147' {$ProductSKU = "Product Datacenter WS Server Core";break} 
    '147' {$ProductSKU = "Product Standard WS Server Core";break} 
    Default {$ProductSKU = "Undefined"} 
} 

Return ($OS + " " + $ProductSKU) 
+0

国际海事组织硬编码产品名称清单不是一个好的解决方案(不是面向未来)。 –

+0

嗨,这个列表是硬编码在操作系统。所以在我看来,它会变得复杂,使其更具活力。另一种方法是使用win32_OperatingSystem对象的Caption属性,但它是依赖于语言的。 –

相关问题