PowerShell: Get Windows Product Key

Need to retrieve the Windows product key on a machine? It's not as simple as it used to be - depending on how the license was activated, there may not be a traditional key to find at all.

Prerequisites:

  • Privileges: None
  • Module: Built-in, no import needed

Quick Command:

Get-CimInstance -ClassName SoftwareLicensingService | Select-Object OA3xOriginalProductKey

Example Output:

OA3xOriginalProductKey
----------------------

An empty result here doesn't mean the command failed - see below for why.

📦
Want all of them at once?
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.

How It Works:

  • Get-CimInstance -ClassName SoftwareLicensingService queries Windows' licensing service for activation and product key details.
  • OA3xOriginalProductKey returns the OEM product key embedded in the UEFI/BIOS firmware at the factory - this only exists on OEM machines that shipped with a key burned into the firmware (common with brands like Dell, HP, or Lenovo).
  • If this is empty, it doesn't mean the query is broken - it means this particular type of key simply isn't present on the machine.

Why Is the Result Often Empty?

Whether this command returns anything depends entirely on how Windows was activated:

  • OEM firmware key - present only on machines that shipped with Windows preinstalled and a key burned into the BIOS/UEFI. This is what OA3xOriginalProductKey retrieves.
  • Digital license - increasingly common on Windows 11 and upgraded systems. The license is tied to a hardware hash or Microsoft account instead of a 25-character key, so there's no key to retrieve - not from firmware, not from the registry, not anywhere.
  • Retail/volume license key - stored differently and isn't exposed through OA3xOriginalProductKey at all.

Checking the Activation Type:

Before assuming the command is broken, it's worth checking which activation type the machine actually has:

slmgr /dli

This opens a popup window (via Windows Script Host) showing the license status - including the channel (Retail, OEM, Volume), and a partial product key (only the last 5 characters, for security reasons - not the full 25-character key).

Name: Windows(R), Professional edition
Description: Windows(R) Operating System, RETAIL channel
Partial Product Key: 3V66T
License Status: Licensed

If the channel says RETAIL or OEM, a full key does exist somewhere (firmware or registry) - OA3xOriginalProductKey may still come back empty if it wasn't OEM-burned into firmware. If the channel or status mentions a Digital License, there's no traditional key to retrieve at all - that's expected, not a missing feature.