To retrieve your Windows product key using PowerShell, open PowerShell as Administrator and run a specific WMI query that reads the key from the system firmware (on modern Windows 10/11 systems) or registry. This method works only on the installed Windows copy and requires local admin rights. No third-party tools or internet access are needed, and the key retrieved is the one originally used to activate the device.
What You'll Need
- A Windows 10 or Windows 11 computer
- Local Administrator privileges on the device
- PowerShell (pre-installed on all supported Windows versions)
Step-by-Step
- Press Windows + X on your keyboard to open the Quick Access menu.
- Click Windows PowerShell (Admin) or Terminal (Admin) (if you have Windows Terminal installed and it's configured to default to PowerShell). If you see "Windows PowerShell" and "Windows PowerShell (Admin)" as separate options, choose the one with "(Admin)" in the label.
- A User Account Control (UAC) prompt may appear. Click Yes to allow PowerShell to run with administrative rights. If you're not signed in as an administrator, you'll need to enter admin credentials.
- In the PowerShell window, type the following command exactly as shown and press Enter:
powershell -Command "(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey"
Alternatively, for Windows 10 version 1803 and later (including Windows 11), you can use this more reliable method:powershell -Command "(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey"
Both commands perform the same action in practice on current systems. - Wait a moment. If successful, your 25-character product key (formatted as XXXXX-XXXXX-XXXXX-XXXXX-XXXXX) will appear in the console output. It may take a few seconds to display.
- Copy the key when it appears and store it securely. Close PowerShell by typing
exitand pressing Enter, or by clicking the X in the top-right corner.
Common Mistakes
- Running PowerShell without administrator privileges: The command will return blank or an error because non-admin users cannot access the SoftwareLicensingService WMI class.
- Typing the command incorrectly: Missing spaces, using straight quotes instead of straight apostrophes (e.g., ‘ instead of ‘), or misspelling ‘SoftwareLicensingService’ will cause the query to fail.
- Using the wrong WMI class: Some guides suggest using ‘Win32_OperatingSystem’ or ‘SoftwareLicensingProduct’, but these do not reliably return the original product key on UEFI-based machines with OEM activation.
- Assuming the key is stored in the registry: While older Windows versions stored keys in the registry, modern Windows stores them in firmware (UEFI), and the registry key path (e.g., HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId) no longer contains the readable key—hence the need for the WMI method.
Tips
- Run the command once, then paste it into a text file or note-taking app. Avoid sharing the key publicly or storing it in unencrypted files.
- If you have multiple Windows installations (e.g., dual-boot), run the command on each partition to retrieve their respective keys.
- For volume-licensed devices (e.g., enterprise environments), the key returned may be a generic KMS client key, not the unique device key. In such cases, contact your organization’s IT department for the specific product key.
- You can also run the command in a single line without typing ‘powershell -Command’ if you’re already inside an elevated PowerShell session. Just type:
(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey
Troubleshooting
If the command returns a blank line, error, or no output, follow these steps:
- Verify you’re running as Administrator: Right-click the Start button again and re-open PowerShell with Admin rights. Confirm the window title says ‘Administrator: Windows PowerShell’.
- Check for typos: Re-type the command manually. Common errors include extra spaces between parts of the command or using smart quotes (e.g., “ or ”) instead of straight quotes. Type the command directly into the PowerShell window, not via copy-paste from untrusted sources.
- Try the alternative WMI query: Run this variation:
powershell -Command "& { $key = (Get-WmiObject -Query 'SELECT * FROM SoftwareLicensingService').OA3xOriginalProductKey; if ($key) { $key } else { Write-Host 'Key not found or system uses MAK/KMS' } }"
This wrapped version checks for null values and prints a message if the key isn’t accessible. - Confirm activation status: Run
slmgr /dliin Command Prompt (run as admin). If it shows ‘Volume: 0’ and ‘Activation Type’ as ‘GRACE’ or ‘Unlicensed’, the system may lack a valid embedded key. - Check hardware and BIOS: On some OEM systems (e.g., older Dell, HP), the OEM key may be stored in the ACPI table instead of UEFI firmware. In rare cases, the key is only available via manufacturer tools. Try downloading your system’s support toolkit (e.g., Dell SupportAssist) or contact the manufacturer.
- Check for modified or OEM-specific builds: Some custom or OEM builds (especially in education or corporate environments) disable WMI access to the product key. If you see ‘Access Denied’ or ‘Invalid Query’, your system policies may block this method.
Frequently Asked Questions
Does this method work on Windows 7 or 8?
Yes, but only if the system uses UEFI firmware or has the key stored in WMI. For many Windows 7 systems with legacy BIOS, the command may return blank. In such cases, try third-party tools like ProduKey (from NirSoft), but only download from official sources. Alternatively, check the COA sticker on the device or original packaging.
Can I use this to activate Windows on another computer?
No. The product key retrieved is tied to the original device’s hardware. Retail keys can be transferred once, but OEM keys are permanently bound to the motherboard. Using an OEM key on a different machine will fail activation and may violate Microsoft’s licensing terms.
Why does the key show as all Xs (XXXXX-XXXXX-XXXXX-XXXXX-XXXXX)?
This usually means the system uses a generic volume license key (GVLK) or KMS client setup. Enterprise or volume-licensed installations often hide the actual key for security. You’ll need to retrieve the specific key from your organization’s activation server or documentation.
Is it safe to run this PowerShell command?
Yes. The command only reads data from your local system and does not send anything over the internet. It is a standard Windows Management Instrumentation (WMI) query supported by Microsoft. However, always verify the command text before pasting into PowerShell to avoid executing malicious scripts.
What if I lost my product key and this returns nothing?
First, check the Certificate of Authenticity (COA) sticker on your computer (often on the bottom of laptops or side of desktops). If missing, look in your email for the original purchase confirmation if you bought Windows separately. You can also use Microsoft’s online tool: go to Settings > Update & Security > Activation, and sign in with your Microsoft account—if your device is linked, activation status may show as digital entitlement, meaning reinstallation will auto-activate.
Does this work on ARM64 or Surface devices?
Yes. Modern ARM64-based devices (including Surface Pro X and newer Surface models) store the key in UEFI firmware and support this method. Run the command in 64-bit PowerShell (not the ARM32 compatibility shell). If using Windows Terminal, ensure you select the correct PowerShell profile.