2017-10-13 5 views
0

Je dois récupérer le nom du système d'exploitation à partir de WMI. Y a-t-il un moyen de le récupérer non localisé? Pour l'instant, je passe les paramètres régionaux US mais le nom de système d'exploitation récupéré est toujours en langue russe.WMI - obtenir le nom de système d'exploitation non localisé

J'utilisé les suivants:

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

Toutes les idées?

+1

Pourquoi faut-il venir de WMI? – Clijsters

Répondre

1

Malheureusement, il n'y a pas de propriété générique dans WMI contenant le nom du système d'exploitation. Cependant, avec ce petit morceau de code que vous pouvez obtenir des informations dont vous avez besoin:

$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

IMO codant en dur une liste de noms de produits n'est pas une bonne solution (non pérenne). –

+0

Bonjour, cette liste est codée en dur dans le système d'exploitation. Donc, à mon avis, il sera compliqué de le rendre plus dynamique. L'autre alternative consiste à utiliser la propriété Caption de l'objet win32_OperatingSystem mais elle dépend de la langue. –