Reputation: 2807
I need to retrieve the OS name from WMI. Is there a way to retrieve it unlocalized? At the moment, I am passing the locale US but the OS name retrieved is still in russian locale.
I used the following:
(Get-WmiObject -Class Win32_OperatingSystem -Locale ms_409).Name
Any ideas?
Upvotes: 0
Views: 885
Reputation: 245
unfortunately there no language-generic property in WMI containing Operating System name. However with this little piece of code you can get information you need :
$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)
Upvotes: 3