Querying Microsoft Office License Keys

Querying Microsoft Office License Keys with Goverlan

Querying installed Microsoft Office license keys has gotten a bit more difficult since Office 2010. In this short recorded demo we show how you can:

  1. Execute a PowerShell script on a remote machine that extracts the license key and writes it to a registry value
  2. Run a report on that registry value so you can see details on the installed license
  3. Perform the same thing against many machines at once.

This process will work for both 32 bit and 64 bit versions, as well as Office 365 installations.

Here is the sample PowerShell script used the example:

$Office15 = “C:\program files (x86)\Microsoft Office\Office15\OSPP.VBS”
$Office15x64 = “C:\program files\Microsoft Office\Office15\OSPP.VBS”
$office16 = “C:\program files (x86)\Microsoft Office\Office16\OSPP.VBS”
$Office16x64= “C:\program files\Microsoft Office\Office16\OSPP.VBS”
if ((Test-Path $Office15) -eq $True)

{$key = cscript $Office15.ToString() /dstatus | Out-String -Stream | Select-String -pattern “key:”}

Elseif ((Test-Path $Office15x64) -eq $True)

{$key = cscript $Office15x64.ToString() /dstatus | Out-String -Stream | Select-String -pattern “key:”}

elseif ((Test-Path $Office16) -eq $True)

{$key = cscript $Office16.ToString() /dstatus | Out-String -Stream | Select-String -pattern “key:”}

Elseif((Test-Path $Office16x64) -eq $True)

{$key = cscript $Office16x64.ToString() /dstatus | Out-String -Stream | Select-String -pattern “key:”}
$keystring = $key.ToString()

$officekey = $keystring.TrimStart(“Last 5 characters of installed product key:”)

New-ItemProperty -Path “HKLM:\Software\Microsoft\Office” -Name “OfficeKey” -PropertyType “String” -Value $officekey -Force

Thanks for reading/watching. Please share comments, suggestions, improvement, feeling, etc! Next week’s demo will be discussing Goverlan WMIX, sign up here: https://zoom.us/webinar/register/fbe1772ddcff934f7510d14dfea9e911


Leave a Reply