How to get Microsoft Office product key without using third party software

If you have lost your Microsoft Office product key or forgotten where you had stored it and can no longer retrieve it, do not despair. I would like to share a simple solution to extract your Office product key from the OS installed on your PC without using any third party software.

  1. Open Notepad.
  2. Copy and paste the following text into the Notepad window
    function Get-MSOfficeProductKey {
        param(
        [string[]]$computerName = "."
        )
    
        $product = @()
        $hklm = 2147483650
        $path = "SOFTWARE\Microsoft\Office"
    
        foreach ($computer in $computerName) {
    
            $wmi = [WMIClass]"\\$computer\root\default:stdRegProv"
    
            $subkeys1 = $wmi.EnumKey($hklm,$path)
            foreach ($subkey1 in $subkeys1.snames) {
                $subkeys2 = $wmi.EnumKey($hklm,"$path\$subkey1")
                foreach ($subkey2 in $subkeys2.snames) {
                    $subkeys3 = $wmi.EnumKey($hklm,"$path\$subkey1\$subkey2")
                    foreach ($subkey3 in $subkeys3.snames) {
                        $subkeys4 = $wmi.EnumValues($hklm,"$path\$subkey1\$subkey2\$subkey3")
                        foreach ($subkey4 in $subkeys4.snames) {
                            if ($subkey4 -eq "digitalproductid") {
                                $temp = "" | select ComputerName,ProductName,ProductKey
                                $temp.ComputerName = $computer
                                $productName = $wmi.GetStringValue($hklm,"$path\$subkey1\$subkey2\$subkey3","productname")
                                $temp.ProductName = $productName.sValue
    
                                $data = $wmi.GetBinaryValue($hklm,"$path\$subkey1\$subkey2\$subkey3","digitalproductid")
                                $valueData = ($data.uValue)[52..66]
    
                                # decrypt base24 encoded binary data 
                                $productKey = ""
                                $chars = "BCDFGHJKMPQRTVWXY2346789"
                                for ($i = 24; $i -ge 0; $i--) { 
                                    $r = 0 
                                    for ($j = 14; $j -ge 0; $j--) { 
                                        $r = ($r * 256) -bxor $valueData[$j] 
                                        $valueData[$j] = [math]::Truncate($r / 24)
                                        $r = $r % 24 
                                    } 
                                    $productKey = $chars[$r] + $productKey 
                                    if (($i % 5) -eq 0 -and $i -ne 0) { 
                                        $productKey = "-" + $productKey 
                                    } 
                                } 
                                $temp.ProductKey = $productKey
                                $product += $temp
                            }
                        }
                    }
                }
            }
        }
        $product
    }
    
  3. Save the text above into a file with the ".ps1" extension on the Desktop.
    Bonus tip: To make sure that you save the file correctly with the ".ps1" extension, you can type its name in double quotes, for example, "office.ps1".office key
  4. Now you must determine if you have a 32-bit version of Office or 64-bit. If you have Office 2007, 2003 or earlier, then you have a 32-bit version as there was no 64-bit version released. Also, if your Windows is 32-bit, then your Office is also 32-bit because 64-bit apps cannot run on 32-bit Windows.
  5. If you have 64-bit Windows and if you run Office 2010, 2013 or 2016, it can either be 32-bit or 64-bit. To determine this, start any Office application such as Word, OneNote, Excel etc.
  6. Click File and then Help in the File menu. On the right, under the About... section, you will see it listed whether it's 32-bit or 64-bit.
  7. Now you must open Powershell as administrator. If you are running 32-bit Office, open the 32-bit version of PowerShell. If you are running 64-bit Office, open 64-bit PowerShell. Type "powershell" into the search box of the Start Menu or right on the Start Screen. On 64-bit Windows, the shortcut named 'Windows PowerShell (x86)' is the 32-bit version of PowerShell and the one without 'x86' in its name is the 64-bit PowerShell. Right click it and choose Run as administrator or select the correct shortcut with the keyboard and press CTRL+SHIFT+Enter. This will open an elevated PowerShell window.
  8. Enable the execution of local files which are not digitally signed. This can be done with the following command (you can copy-paste it):
    Set-ExecutionPolicy RemoteSigned

    Press Enter to allow the execution policy to be changed. Windows PowerShell

  9. Now you should type the following command:
    Import-Module C:\Users\Winaero\Desktop\office.ps1; Get-MSOfficeProductKey

    Note: You must change the path in the command above, including your user name folder, to correctly point to the location where you saved the office.ps1 file.

  10. Voila, your Office product key will be displayed on the screen!

Thanks to our reader "bosbigal" for sharing this script.

10 thoughts on “How to get Microsoft Office product key without using third party software

  1. Phil

    i move away from crap OS
    i moved to Linux Lite OS
    http://i.imgur.com/YG77oKs.png

    Poorly-rated. Like or Dislike: Thumb up 0 Thumb down 4

    Reply
    1. Sergey Tkachenko Post author

      Which distro?

      Like or Dislike: Thumb up 0 Thumb down 0

      Reply
      1. Phil

        linuxliteos.com

        Like or Dislike: Thumb up 0 Thumb down 1

        Reply
        1. Sergey Tkachenko Post author

          Ah, so you are using XFCE4 now :)

          Like or Dislike: Thumb up 0 Thumb down 0

          Reply
          1. Phil

            yup

            Like or Dislike: Thumb up 0 Thumb down 0

  2. Steve

    Didn’t work for me. Using Windows 7 Pro, 64-bit Office 2016, 64-bit Powershell in Admin Mode, Ran both commands, no output on second one with the key. Thanks anyway.

    Like or Dislike: Thumb up 1 Thumb down 0

    Reply
  3. Juliano

    The key result is diferent from key installed?
    Why?

    Like or Dislike: Thumb up 0 Thumb down 0

    Reply
    1. Sergey Tkachenko Post author

      for which edition of MS Office?

      Like or Dislike: Thumb up 0 Thumb down 0

      Reply
  4. Rob

    Didn’t work for me on Win 10, I followed the steps accurately

    Like or Dislike: Thumb up 0 Thumb down 0

    Reply
  5. James

    As many others have commented, this script doesn’t work at all with Windows 10.

    Like or Dislike: Thumb up 0 Thumb down 0

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *