Welcome to MSDN Blogs Sign in | Join | Help

Get-OSSku.ps1

Nitin Bhat the WMI PM recently pointed HERE to answer the question, how do know what OS SKU a machine is running?

You can run the expression $((gwmi win32_operatingsystem).OperatingSystemSKU) to the the value and then look it up on that table.

I decided to turn it into a script you can use.  It is rock-simple but it saves you the typing and there's some value in that.  I've included it below and attached it as well.

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

$sku = $((gwmi win32_operatingsystem).OperatingSystemSKU)
switch ($sku)
{
    0       {"Undefined";break}
    1       {"Ultimate Edition";break}
    2       {"Home Basic Edition";break}
    3       {"Home Basic Premium Edition";break}
    4       {"Enterprise Edition";break}
    5       {"Home Basic N Edition";break}
    6       {"Business Edition";break}
    7       {"Standard Server Edition";break}
    8       {"Datacenter Server Edition";break}
    9       {"Small Business Server Edition";break}
    10       {"Enterprise Server Edition";break}
    11       {"Starter Edition";break}
    12       {"Datacenter Server Core Edition";break}
    13       {"Standard Server Core Edition";break}
    14       {"Enterprise Server Core Edition";break}
    15       {"Enterprise Server Edition for Itanium-Based Systems";break}
    16       {"Business N Edition";break}
    17       {"Web Server Edition";break}
    18       {"Cluster Server Edition";break}
    19       {"Home Server Edition";break}
    20       {"Storage Express Server Edition";break}
    21       {"Storage Standard Server Edition";break}
    22       {"Storage Workgroup Server Edition";break}
    23       {"Storage Enterprise Server Edition";break}
    24       {"Server For Small Business Edition";break}
    25       {"Small Business Server Premium Edition";break}
    default {"<UNKNOWN:$SKU>"}
}

Published Saturday, June 14, 2008 4:56 AM by PowerShellTeam
Filed under:

Attachment(s): Get-OSSKU.ps1

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Get-OSSku.ps1

Useful script, just note that it only works on Vista and WS2008.

Tuesday, June 17, 2008 9:04 AM by Per Østergaard

# Interesting Links - 6/18/2008

To DEP or not to DEP – A good post on DEP from the Performance Team Windows XP era draws to a close –

Wednesday, June 18, 2008 8:32 AM by Matt Johnson's Technical Adventures

# re: Get-OSSku.ps1

Nice, very useful.  Still learning PowerShell, just curious why he used the outer parenthesis.  Why "$((gwmi win32_operatingsystem).OperatingSystemSKU)" instead of "$(gwmi win32_operatingsystem).OperatingSystemSKU"

Thursday, June 19, 2008 9:10 AM by Josh

# re: Get-OSSku.ps1

Here's an improved version taking the computer name and version number into account:

#Requires -Version 1

# GetOSSku.ps1

# Get OS SKU

function global:Get-OSSku

{

param([string] $computerName)

if(($computerName -eq $null) -or ($computerName -eq ""))

{

$computerName = "localhost"

}

Write-Host

"Computer:`t" + $computerName.ToUpper()

$wmi = $(gwmi Win32_OperatingSystem -computerName $computerName)

$sku = $wmi.OperatingSystemSKU

"Version:`t" + $wmi.Version

"SKU:`t`t" + $(

switch($sku)

{

0        {"Undefined"; break}

1        {"Ultimate Edition"; break}

2        {"Home Basic Edition"; break}

3        {"Home Basic Premium Edition"; break}

4        {"Enterprise Edition"; break}

5        {"Home Basic N Edition"; break}

6        {"Business Edition"; break}

7        {"Standard Server Edition"; break}

8        {"Datacenter Server Edition"; break}

9        {"Small Business Server Edition"; break}

10       {"Enterprise Server Edition"; break}

11       {"Starter Edition"; break}

12       {"Datacenter Server Core Edition"; break}

13       {"Standard Server Core Edition"; break}

14       {"Enterprise Server Core Edition"; break}

15       {"Enterprise Server Edition for Itanium-Based Systems"; break}

16       {"Business N Edition"; break}

17       {"Web Server Edition"; break}

18       {"Cluster Server Edition"; break}

19       {"Home Server Edition"; break}

20       {"Storage Express Server Edition"; break}

21       {"Storage Standard Server Edition"; break}

22       {"Storage Workgroup Server Edition"; break}

23       {"Storage Enterprise Server Edition"; break}

24       {"Server For Small Business Edition"; break}

25       {"Small Business Server Premium Edition"; break}

default  {"<UNKNOWN:$SKU>"}

}

)

Write-Host

}

# EOF

Wednesday, November 12, 2008 9:07 AM by Markus

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker