Created
February 5, 2015 19:35
-
-
Save wpsmith/c7e3de2335f1ffb6607a to your computer and use it in GitHub Desktop.
PowerShell: Gets SharePoint License Key for SharePoint Server 2007, 2010, or 2013.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how can i run this ps1 file? pls help