Home » PowerShell » PowerShell Get Activation Key for Windows

PowerShell Get Activation Key for Windows

Use the PowerShell cmdlet Get-WmiObject or the wmic command in command-prompt to get the activation key for the Windows operating system. Windows activation product key is stored in the OA3xOriginalProductKey property.

PowerShell Get-WmiObject cmdlet uses the SoftwareLicensingServer class to get the activation key for the Windows OS using the property OA3xOriginalProductKey. It returns the product key in the format "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"

Command line wmic is also used to find the activation key for the Windows OS.

In this article, we will discuss how to retrieve the product key for the Windows OS using PowerShell and cmd.

Find the Product Activation Key using PowerShell

To retrieve the activation key for Windows OS in PowerShell, use the following script.

Get-WmiObject -query 'select * from SoftwareLicensingService' | Select OA3xOriginalProductKey

In the above PowerShell script, the Get-WmiObject cmdlet uses the SoftwareLicensingService class that stores the product key in the property OA3xOriginalProductKey.

The output of the above PowerShell scripts gets the activation key for the Windows OS.

PowerShell Get Activation Key for Windows
PowerShell Get Activation Key for Windows

Retrieve the Windows Product Key using Cmd

Use the wmic command in Command Prompt to get the Windows product key.

wmic path softwarelicensingservice get OA3xOriginalProductKey

In the above command, the wmic uses the path parameter to get the OA3xOriginalProductKey property from the class softwarelicensingservice that stores the activation key.

The output of the above command is:

OA3xOriginalProductKey
XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

Note: Get the activation key using PowerShell and Cmd commands are tested on Windows 10.

Conclusion

I hope the above article on how to get an activation key using PowerShell and cmd is helpful to you.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.