Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Windows edition?

I need to create a script in PowerShell that verifies the OS edition (Pro, Enterprise, Home, etc.). I have found many information about how to verify with an ID number the OS version (Vista, 7, 8, 8.1, etc.), but I can't find anything about the editions codes. My questions are:

  1. Are there codes for Windows editions?
  2. If there are no codes, and the only way is Get-WmiObject -Class Win32_OperatingSystem | % Caption, how can I format this to select the edition on any windows operating system?
  3. Are there other ways to do this?

https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx

like image 903
kimo pryvt Avatar asked Oct 20 '25 11:10

kimo pryvt


2 Answers

That information is encoded in the OperatingSystemSKU property of the Win32_OperatingSystem class:

Value  Meaning
-----  -------
    0  Undefined
    1  Ultimate Edition
    2  Home Basic Edition
    3  Home Premium Edition
    4  Enterprise Edition
    5  Home Basic N Edition
    6  Business Edition
    7  Standard Server Edition
    8  Datacenter Server Edition
    9  Small Business Server Edition
   10  Enterprise Server Edition
   11  Starter Edition
   12  Datacenter Server Core Edition
   13  Standard Server Core Edition
   14  Enterprise Server Core Edition
   15  Enterprise Server Edition for Itanium-Based Systems
   16  Business N Edition
   17  Web Server Edition
   18  Cluster Server Edition
   19  Home Server Edition
   20  Storage Express Server Edition
   21  Storage Standard Server Edition
   22  Storage Workgroup Server Edition
   23  Storage Enterprise Server Edition
   24  Server For Small Business Edition
   25  Small Business Server Premium Edition
   29  Web Server, Server Core
   39  Datacenter Edition without Hyper-V, Server Core
   40  Standard Edition without Hyper-V, Server Core
   41  Enterprise Edition without Hyper-V, Server Core
   42  Hyper-V Server

Put the above list in a hashtable for mapping the integer value to the description:

$editions = @{
  0  = 'Undefined'
  1  = 'Ultimate Edition'
  2  = 'Home Basic Edition'
  ...
  41 = 'Enterprise Edition without Hyper-V, Server Core'
  42 = 'Hyper-V Server'
}

$sku = (Get-WmiObject Win32_OperatingSystem).OperatingSystemSKU

'Edition is {0}.' -f $editions[$sku]

Note, however, that OperatingSystemSKU is not available on Server 2003 and earlier. On those systems you'll have to check the Caption and/or OSProductSuite property.

like image 117
Ansgar Wiechers Avatar answered Oct 23 '25 02:10

Ansgar Wiechers


You can also use 'Get-WindowsEdition -online'.

Ref: https://learn.microsoft.com/en-us/powershell/module/dism/get-windowsedition

like image 28
Will I Am Avatar answered Oct 23 '25 02:10

Will I Am



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!