Yes, you can extract your Windows product key directly from your system using PowerShell, the built-in command-line utility in Windows. This method works for all versions of Windows (including Pro, Home, Enterprise, etc.) and requires no extra software or admin rights beyond what your system already has. Run it as a standard user, as the key is stored in system files.

What You'll Need

  • Windows PC with PowerShell installed (most modern Windows versions include it by default).
  • Admin rights are not required—you’ll extract the key from system files.

Step-by-Step

  1. Open PowerShell. Press Win + X on Windows and select Windows Terminal (or PowerShell), then choose Terminal (Admin) if prompted for UAC elevation. Alternatively, search for PowerShell in the Start menu and run it as an admin if needed. Note: If you’re on Windows 10/11, this is the default method.
  2. Run the following command to extract the product key from the Windows registry: Get-ChildItem -Recurse -ErrorAction SilentlyContinue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-String -Pattern '^ProductId:' | Select-Object -ExpandProperty Line This scans the registry for the product ID field, which contains the key.
  3. If the command returns no results, try this alternative method to fetch the key from the Windows update catalog: powershell -Command "Get-WindowsOptionalFeature -Online -FeatureName 'Microsoft-Windows-Shell-L2DV' | Select-Object -ExpandProperty InstallStatus" | Select-String -Pattern 'ProductKey:' This checks for the key stored in Windows Update settings.
  4. If neither method works, try this direct registry query (adjust path for older Windows versions): Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Where-Object { $_.PSChildName -eq 'ProductId' } | Select-Object PSChildName, ProductId Looks for the ProductId value in the registry key.
  5. If you still don’t see the key, check the system’s original installation type. The key may be embedded in the Windows image itself. Try this for Windows 10/11: Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -ExpandProperty LocalAccountTokenInformation | ConvertTo-Json This extracts the key from the original Windows installation file.

    If that fails, the key may not be visible—your Windows may have been activated via a digital license (e.g., OEM, cloud licensing).

Common Mistakes

Skipping UAC elevation: Running PowerShell as a standard user may prevent access to the registry or update catalog. Always run it as admin unless you’re certain no extra permissions are needed.

Misinterpreting results: The registry sometimes stores the key as a hex string or truncated value. Use PowerShell’s ConvertFrom-Hex to decode it if needed.

Using outdated commands: Windows 7 or older may lack registry keys. Try the slmgr command (see Troubleshooting) instead.

Tips

For Windows 10/11, enable PowerShell’s logging to debug issues: Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run' -Name 'PowerShellLog' -Value 'notepad.exe $LOGFILE'

Always verify the key matches your hardware before using it in a new installation.

If the key is part of a digital license, it may be tied to your Microsoft account or hardware—retyping it won’t reactivate Windows.

Troubleshooting

If PowerShell commands fail with "Access Denied," try these fixes:

  1. Reboot your PC and retry. Sometimes UAC delays cause temporary access issues.
  2. Open PowerShell as an admin and run: icacls "HKLM:\SOFTWARE\Microsoft" /grant Administrators:F This grants full permissions to registry keys. Run this only once.
  3. Use the built-in slmgr command to check activation status: slmgr /dlv This lists all installed licenses, including the product key.
  4. If the key is missing entirely, your Windows may have been activated via:
    • Digital license (OEM/Cloud/Enterprise)
    • Manual key entry during setup
    In this case, you’ll need to obtain the key from the original retailer or Microsoft support.

Frequently Asked Questions

How do I get my Windows product key if PowerShell fails?

If PowerShell methods don’t work, try the slmgr tool: slmgr /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

Replace XXXXX with your key, then run slmgr /ato to reactivate.

Can I extract the key from a Windows ISO file?

Yes, use PowerShell to dump the ISO’s contents: Expand-Archive -Path "C:\path\to\Windows.iso" -DestinationPath "C:\temp" -Force Then search for ProductKey in the extracted files.

Why isn’t my key showing up in registry queries?

If the registry is corrupted or the key was deleted, try: regedit > Navigate to HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion > Check if ProductId exists. If missing, your Windows may be digitally licensed.

How do I verify if a key is valid?

Insert the key and run: slmgr /ipk [KEY] && slmgr /ato

If activation succeeds, the key is valid for your hardware.

Can I use this method to get a key for a virtual machine?

No. VMs often use dynamic licensing (Microsoft’s vmgenome or vmgen keys). Extract the key from your VM’s settings or use Microsoft’s slmgr for virtual machines.

What if my key is part of a cloud/enterprise license?

Cloud licenses (Microsoft 365, Azure AD) use digital keys tied to your account. You’ll need to request the key from your admin or Microsoft support.

How do I find my key during Windows setup?

During a clean install, you can enter the key during the setup process. If you skip this step, you’ll need to activate later with slmgr /ato.