WMI - 获取未本地化的操作系统名称

时间:2017-10-13 07:48:39

标签: windows powershell localization wmi get-wmiobject

我需要从WMI中检索操作系统名称。有没有办法检索它未本地化? 目前,我正在通过美国的语言环境,但检索到的操作系统名称仍然是俄语语言环境。

我使用了以下内容:

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

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

遗憾的是,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)