Remove Office 365 license from a Computer with PowerShell or CMD

1) First, we need to open PowerShell or CMD in Administrator mode. Click on Start and type PowerShell and right click on the icon. Select Run as Administrator

2)List Current License

If you are using PowerShell run the following command to list activated licenses:
 
cscript "$Env:Programfiles\Microsoft Office\Office16\OSPP.VBS" /dstatus

If you are using CMD then run the following cmd:
 
cscript "%Programfiles%\Microsoft Office\Office16\OSPP.VBS" /dstatus
 


3)List out expiring key
The output of the command looks like below. There could be more than one key listed, so look for a license with a REMAINING GRACE or Grace Periode Expired line just above the last 5 characters of the product key.
Take a note of the 5 last characters of the product key that we need to remove.


4)Removing the product key

Run the command below to remove the license that is or is about to expire. Replace with the 5 characters of the product key:
cscript "$Env:Programfiles\Microsoft Office\Office16\OSPP.VBS" /unpkey:<key>

The command if you are using CMD:
 
cscript "%Programfiles%\Microsoft Office\Office16\OSPP.VBS" /unpkey:<key>

Comments