Unlicense Office suite using last 5 characters

The following information demonstrates a manual and automated way to remove the subscription within an Office suite.

Manual process

Step 1: Open Command Prompt on PC

Open a Command Prompt window, and then take one of the following actions:

• If you installed the 64-bit version of Office 2016, move to the following folder: C:\Program Files\Microsoft Office\Office16

• If you installed the 32-bit version of Office 2016, move to the following folder: C:\Program Files (x86)\Microsoft Office\Office16

Step 2: Display the Current License(s)

Type the following command to display the license status. Note the last five characters of any and all license keys that display in the output:

cscript ospp.vbs /dstatus

Step 3: Remove the License(s)

Now run the following command as many times as needed to remove all of the license keys you noted from the previous step.

cscript ospp.vbs /unpkey:<last five characters of product key>

Step 4: Restart the Computer

Once the remove commands are successfull, close the command prompt and restart the PC.

Step 5: Reactivate MS Office 2016 with New Account

Launch one of the MS Office 2016 applications. The application should prompt you to reactivate the by providing your sign-on ID. Enter in the new user’s credentials and the software will now be licensed under their ID.

This script will gather all the Office suite subscriptions and then filter out to export only the

Automated Script

This will export all the Office licensed products to a txt file called ‘officekey’, it will then export only the office 365 suite subscription to another file called ‘officekey2’  

This key which contains the last 5 characters will then be used in the last commands to unlicense the office suite

###It will export all the Office licensed products to a txt file cqalled 'officekey', it will then export only the office 365 subscription to another file called 'officekey2'
###This key which contains the last 5 characters will then be used in the last commands to unlicense the office suite



#cd "C:\Program Files\Microsoft Office\Office16\"
#$key = (cscript OSPP.VBS /dstatus | findstr /C:"Last 5 characters of installed product key: ").replace("Last 5 characters of installed product key: ","").trim()
#$key > C:\officekey.txt
#keyout > c:\officekey2.txt

cd "C:\Program Files\Microsoft Office\Office16\"
$textfile = cscript OSPP.VBS /dstatus 
$textfile > C:\officekey.txt
sleep 15
$text = Get-Content 'C:\officekey.txt'


$output = $text -split "`n"
$row = 0
$keyrow = 0
$token = ""
$output | Foreach-Object { 
$row++;
Write-Host $_.ToString()
if ($_.ToString().Trim() -eq "LICENSE NAME: Office 16, Office16O365ProPlusR_Subscription1 edition") {
    $keyrow = $row + 7;
    
}
if ($row -eq $keyrow) {
    $token = $_.ToString().Trim().Split(":")[1].Trim();
   
}
}


Write-output $token | out-file c:\officekey2.txt

sleep 15

$keyout = Get-Content 'C:\officekey2.txt'
cscript ospp.vbs /unpkey:$keyout
Share
Ryan Wilson
Azure and Office 365 Technical Architect | Microsoft Certified Solutions Associate: Office 365 | Microsoft Certified: Azure Solutions Architect Expert | Microsoft Certified Solutions Expert: Productivity | Microsoft 365 Certified: Enterprise Administrator Expert | Microsoft 365 Certified: Messaging Administrator Associate

Leave a Reply

Your email address will not be published. Required fields are marked *