Issue:
When user start any of Microsoft Office desktop appliction they are getting this error message:
Signing out/in from Office 365 and trying to activate the installation again didn’t help.
Solution:
To solve this issue you have to run the OSPP.vbs script located in the Office installation folder as in the screenshot below. Running the script with the /unpkey parameter removes the existing license and forces the user/client to re-register
- Run command prompt as administrator
- Navigate to the C:\Program Files (X86)\Microsoft Office\Office15(or 16) directory and execute the OSPP script:
- “c:\program files (86)\Microsoft Office\Office16\cscript ospp.vbs” /dstatus
The last 5 characters of the installed product key are listed as well, please note them or copy them onto the Clipboard.
Find that key and enter this line:
“c:\program files (86)\Microsoft Office\Office15(or 16)\cscript ospp.vbs” /unpkey:last five of key here
The challenge is if we need to run this script on many workstations.
To automate this, here is a simple PowerShell script as a wrapper around OSPP.vbs to automate the key deactivation. It simply locates OSPP.vbs from the installation folder(s), fetches the key(s) and last removes all existing activations. Please note that it needs to run elevated and that it removes ALL activations on the machine.
#Check that the script runs with privileged rights
if
(
-not
(
[Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]
::GetCurrent()).IsInRole(
[Security.Principal.WindowsBuiltInRole]
"Administrator"
))
{
Write-Warning
"You need to have Administrator rights to run this script!`nPlease re-run this script as an Administrator in an elevated powershell prompt!"
break
}
#Find OSPP.vbs path and run the command with the dstatus option (Last 1...)
$OSPP
=
Resolve-Path
-Path
"C:\Program Files*\Microsoft Offic*\Office*\ospp.vbs"
|
Select-Object
-ExpandProperty
Path
-Last
1
Write-Output
-InputObject
"OSPP Location is: $OSPP"
$Command
=
"cscript.exe '$OSPP' /dstatus"
$DStatus
=
Invoke-Expression
-Command
$Command
#Get product keys from OSPP.vbs output.
$ProductKeys
=
$DStatus
|
Select-String
-SimpleMatch
"Last 5"
|
ForEach-Object
-Process
{
$_
.tostring().split(
" "
)[-1]}
if
(
$ProductKeys
) {
Write-Output
-InputObject
"Found $(($ProductKeys | Measure-Object).Count) productkeys, proceeding with deactivation..."
#Run OSPP.vbs per key with /unpkey option.
foreach
(
$ProductKey
in
$ProductKeys
)
{
Write-Output
-InputObject
"Processing productkey $ProductKey"
$Command
=
"cscript.exe '$OSPP' /unpkey:$ProductKey"
Invoke-Expression
-Command
$Command
}
}
else
{
Write-Output
-InputObject
"Found no keys to remove... "
}
Reference: Tailspintoys – 365lab.net by Johan