Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Created February 5, 2015 19:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpsmith/c7e3de2335f1ffb6607a to your computer and use it in GitHub Desktop.
Save wpsmith/c7e3de2335f1ffb6607a to your computer and use it in GitHub Desktop.
PowerShell: Gets SharePoint License Key for SharePoint Server 2007, 2010, or 2013.
<#
.SYNOPSIS
Gets the SharePoint License Key for 2007, 2010, or 2013
.DESCRIPTION
Gets the SharePoint License Key for 2007, 2010, or 2013.
.PARAMETER version
Version of SharePoint installed.
.EXAMPLE
Get-SPLicenseKey 2013
Get-SPLicenseKey -version 2010
Get-SPLicenseKey 2007
.NOTES
AUTHOR: System Center Automation Team
LASTEDIT: Dec 18, 2014
#>
Param(
[Parameter(Mandatory=$True,Position=1)]
[string]
$version
)
$map = "BCDFGHJKMPQRTVWXY2346789"
$property = @{"2007"="12.0";"2010"="14.0";"2013"="15.0"}
# Get Property
$value = (get-itemproperty "HKLM:\SOFTWARE\Microsoft\Office\$($property[$version])\Registration\{90$(($property[$version] -replace '\.',''))000-110D-0000-1000-0000000FF1CE}").digitalproductid[0x34..0x42]
# Begin Parsing
$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
@SaMolPP
Copy link

SaMolPP commented Sep 18, 2016

how can i run this ps1 file? pls help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment