Get-OSSku.ps1

Get-OSSku.ps1

  • Comments 4

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>"}
}

Attachment: Get-OSSKU.ps1
Leave a Comment
  • Please add 3 and 2 and type the answer here:
  • Post
  • Useful script, just note that it only works on Vista and WS2008.

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

  • 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"

  • 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

Page 1 of 1 (4 items)