In a previous tip we explained how you can use slmgr, a built-in VBScript, to check Windows licensing state.
Accessing the Raw Licensing Data in PowerShell
The core information used by this VBScript actually comes from WMI, so in PowerShell, you can directly access the raw licensing data like this:
PS> Get-WmiObject SoftwareLicensingService
You can also check the license status of your copy of Windows:
PS> Get-WmiObject SoftwareLicensingProduct | Select-Object -Property Description, LicenseStatus | Out-GridView
And you can find out which Windows SKU you are actually using:
PS> Get-WmiObject SoftwareLicensingProduct | Where-Object { $_.LicenseStatus -eq 1 } | Select-Object -ExpandProperty Description Windows Operating System - Windows(R) 7, RETAIL channel
To investigate all the other logic found in slmgr, have a look at the VBScript source code:
PS> notepad (Get-Command slmgr).Path