Skip to content

Instantly share code, notes, and snippets.

@kevinblumenfeld
Created November 11, 2019 14:56
Show Gist options
  • Save kevinblumenfeld/4d625f25122c074c02f373729dc2320f to your computer and use it in GitHub Desktop.
Save kevinblumenfeld/4d625f25122c074c02f373729dc2320f to your computer and use it in GitHub Desktop.
$licrem = join-path $env:temp OfficeProPlusLicenseRemoved.txt
if (-not (Test-Path $licrem)) {
$license = cscript "C:\Program Files (x86)\Microsoft Office\Office16\OSPP.VBS" /dstatus
$o365 = 'LICENSE NAME'
for ($i = 0; $i -lt $license.Length; $i++) {
if ($license[$i] -match $o365) {
$i += 6
$keyline = $license[$i]
$prodkey = $keyline.substring($keyline.length - 5, 5)
}
}
cscript "C:\Program Files (x86)\Microsoft Office\Office16\OSPP.VBS" /unpkey:$prodkey
New-Item $licrem
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment