Recover SharePoint 2007 / 2010 / 2013 Product Key using PowerShell

Ever wanted to recover your SharePoint 2007 or SharePoint 2010 Product key from an existing SharePoint Farm? Sure! It’s encoded and stored in the system registry, and we can recover the license key with PowerShell. Here is the code:

PowerShell Script to Recover SharePoint 2007 Product key:

function Get-SP2007ProductKey {    
    $map="BCDFGHJKMPQRTVWXY2346789" 
    $value = (get-itemproperty "HKLM:\SOFTWARE\Microsoft\Office\12.0\Registration\{90120000-110D-0000-1000-0000000FF1CE}").digitalproductid[0x34..0x42]  
    $ProductKey = "";
    for ($i = 24; $i -ge 0; $i--) { 
      $r = 0 
      for ($j = 14; $j -ge 0; $j--) { 
        $r = ($r * 256) -bxor $value[$j] 
        $value[$j] = [math]::Floor([double]($r/24)) 
        $r = $r % 24 
      } 
      $ProductKey = $map[$r] + $ProductKey 
      if (($i % 5) -eq 0 -and $i -ne 0) { 
        $ProductKey = "-" + $ProductKey 
      } 
    } 
    $ProductKey
} 

#Call the function
Get-SP2007ProductKey 

PowerShell Script to Recover SharePoint 2010 Product Key:

function Get-SP2010ProductKey {    
    $map="BCDFGHJKMPQRTVWXY2346789" 
    $value = (get-itemproperty "HKLM:\SOFTWARE\Microsoft\Office\14.0\Registration\{90140000-110D-0000-1000-0000000FF1CE}").digitalproductid[0x34..0x42]  
    $ProductKey = ""  
    for ($i = 24; $i -ge 0; $i--) { 
      $r = 0 
      for ($j = 14; $j -ge 0; $j--) { 
        $r = ($r * 256) -bxor $value[$j] 
        $value[$j] = [math]::Floor([double]($r/24)) 
        $r = $r % 24 
      } 
      $ProductKey = $map[$r] + $ProductKey 
      if (($i % 5) -eq 0 -and $i -ne 0) { 
        $ProductKey = "-" + $ProductKey 
      } 
    } 
    $ProductKey
} 
#Call the function
Get-SP2010ProductKey

Retrieve SharePoint 2013 Product Key:

For SharePoint 2013, Set the $value parameter in the above code to :

$value = (get-itemproperty "HKLM:\SOFTWARE\Microsoft\Office\15.0\Registration\{90150000-110D-0000-1000-0000000FF1CE}").digitalproductid[0x34..0x42]    

and run the script!

Thanks to http://powershell.com/cs/blogs/tips/archive/2012/04/30/getting-windows-product-key.aspx for the idea!

Salaudeen Rajack

Information Technology Professional with Two decades of SharePoint Experience.

10 thoughts on “Recover SharePoint 2007 / 2010 / 2013 Product Key using PowerShell

  • July 30, 2021 at 1:47 AM

    It works on my 2013 Enterprise servers, but on my 2013 Foundation servers I get this error:

    get-itemproperty : Cannot find path
    ‘HKLM:\SOFTWARE\Microsoft\Office\15.0\Registration\{90150000-110D-0000-1000-0000000FF1CE}’
    because it does not exist.
    At line:3 char:13
    + $value = (get-itemproperty “HKLM:\SOFTWARE\Microsoft\Office\15.0\Re …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (HKLM:\SOFTWARE\…0-0000000FF1CE}:String) [Get-It
    emProperty], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand

    and then a dozen screens of “cannot index into a null array” errors.

    Any idea why this doesn’t work on Foundation?

    Reply
  • June 17, 2020 at 10:51 AM

    What is $map=”BCDFGHJKMPQRTVWXY2346789″ key?

    Reply
  • September 29, 2017 at 5:42 PM

    Amazing, I used your script to get the key from an old server with SP2010 and it worked.

    Thank you very much

    Reply
  • April 7, 2017 at 9:57 AM

    it does not work. It recover the key for OS not SharePoint

    Reply
  • September 18, 2016 at 9:06 AM

    awesome.. it works. i received the key from my prod.server But when i apply teh same prod. key for a new VM thats meant for DEV env. , its not working.
    is there any criteria from MS, such that, a license key thats used for prod. can not be used for a another dev. env ?

    thnx
    SaMol

    Reply
  • February 4, 2016 at 2:03 PM

    Does not work. It Recovers the key of the OS.

    Reply
  • August 18, 2015 at 5:10 PM

    Does anyone know what the $value would be for Project Server 2010 please?

    Reply
  • July 24, 2015 at 11:27 AM

    excellect . thankyou

    Reply
  • December 4, 2014 at 3:23 PM

    Fantastic ! Thank you

    Reply
  • December 1, 2014 at 9:38 AM

    Awesome, its works

    Reply

Leave a Reply