If I want to check whether Windows is activated, but I can't be bothered to dive into the menu system or am on a version of Windows without Desktop Experience (such as Server Core), how can I check the activation status using only the command line?
4 Answers
A purely PowerShell solution would be:
Get-CimInstance SoftwareLicensingProduct -Filter "Name like 'Windows%'" |
where { $_.PartialProductKey } | select Description, LicenseStatus
This will give you an output like this:
Description LicenseStatus
----------- -------------
Windows(R) Operating System, OEM_DM channel 1
if LicenseStatus is 1, it means that the system is permanently activated.
Good thing about this is, that you can easily check RemoteMachines, by specifying the -ComputerName Parameter.
Get-CimInstance SoftwareLicensingProduct -Filter "Name like 'Windows%'" -ComputerName RemoteComp |
where { $_.PartialProductKey } | select Description, LicenseStatus
Though I gotta say that slmgr /xpr is faster and also clearer.
- 8,924
- 5
- 28
- 48
-
Are the different numbers documented somewhere? – BrainSlugs83 Aug 23 '20 at 22:17
-
Or `Get-CimInstance SoftwareLicensingProduct -Filter "Name like 'Windows%' and partialproductkey <> null"` – js2010 Jul 29 '22 at 15:08
-
Is there a way to get the expiration date? – js2010 Jul 29 '22 at 15:20
-
2This will save you 14 seconds. `Get-CimInstance SoftwareLicensingProduct -Filter "partialproductkey is not null" | ? name -like windows*` – js2010 Jul 29 '22 at 15:33
On Windows 10 or Windows Server 2016/2019, to display the activation status using the command prompt (or powershell) open your preferred command line tool and enter the following command
slmgr /xpr
a dialog is shown indicating the operating system's activation status. If the operating system is not yet activated, the dialog will indicate it is in 'Notification mode'
If Windows is succesfully activated, the dialog will indicate is is either 'Permanently Activated' as shown below, or if using a time-limited volume license activation the time the activation is due to expire will be shown.
On older versions of Windows (such as Windows 7) the message dialogs will be similar but may have slightly differing text.
This method could also be useful to check the activation status during the out-of-box experience (OOBE) wizard by using Shift + F10 to launch a command prompt, before completing the wizard.
- 465
- 2
- 7
- 17
-
This answer does not work on systems without a GUI, which was an explicit part of the question. If you're running Server Core or are connecting remotely to a headless system, slmgr will return no results or appear to hang. This does work fine for most desktop users, however. – Thomas Aug 08 '23 at 17:19
You can also do
SELECT LicenseStatus FROM SoftwareLicensingProduct
as a WMI query, where values are:
0=Unlicensed
1=Licensed
2=OOBGrace
3=OOTGrace
4=NonGenuineGrace
5=Notification
6=ExtendedGrace
- 17,120
- 4
- 14
- 35
- 31
- 1
- To avoid the popup and
- store the windows version/activation status in a variable
- use
cscriptto runslmgr.vbsand wrap it in a batch file - parse output with a
for /floop
:: Q:\Test\2019\04\07\SU_1422368.cmd
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
Set "WinVerAct="
For /f "tokens=*" %%W in ('
cscript /Nologo "C:\Windows\System32\slmgr.vbs" /xpr
') Do Set "WinVerAct=!WinVerAct! %%W"
if Not defined WinVerAct (
Echo:No response from slmgr.vbs
Exit /B 1
)
Echo Windows Version Activation Status:
Echo:"%WinVerAct:~1%"
Sample output:
> Q:\Test\2019\04\07\SU_1422368.cmd
Windows Version Activation Status:
"Windows(R), Professional edition: Der Computer ist dauerhaft aktiviert."
A single line PowerShell script wrapping slmgr.vbs:
$WinVerAct = (cscript /Nologo "C:\Windows\System32\slmgr.vbs" /xpr) -join ''
- 7,011
- 1
- 15
- 29
-
1and (as a little cherry on top) `Invoke-Command { (cscript /Nologo "C:\Windows\System32\slmgr.vbs" /xpr) -join '' } -ComputerName xy` to check remote machines in PowerShell – SimonS Apr 11 '19 at 10:16

