Remove License Key for Office 365

Comments

4 comments

  • Colby Bouma

    It looks like the script on Spiceworks had weird quote characters. Try this:

    #store the license info into an array
    $license = cscript 'C:\Program Files (x86)\Microsoft Office\Office16\OSPP.VBS' /dstatus
    #license name from /dstatus
    $o365 = "OfficeO365ProPlusR_Subscription1 edition"
    #loop till the end of the array searching for the $o365 string 
    for ($i = 0; $i -lt $license.Length; $i++) {
        if ($license[$i] -match $o365) {
            $i += 6
            #jumping six lines to get to the product key line in the array
            $keyline = $license[$i]
            #extra step
            $prodkey = $keyline.substring($keyline.length – 5, 5)
            #getting the last 5 characters of the line (prodkey)
        } 
    }
    #removing the key from the workstation 
    cscript 'C:\Program Files (x86)\Microsoft Office\Office16\OSPP.VBS' /unpkey:$prodkey
    
    0
    Comment actions Permalink
  • Martin Timmelstad

    Hi Colby, I figured it out!

    Seems that it is not longer called OfficeO365ProPlusR_Subscription1 edition but Office16O365ProPlusR_Subscription1 edition. And lastly it needs to jump 7 rows.

    Here is the correct code.

    #store the license info into an array
    $license = cscript 'C:\Program Files (x86)\Microsoft Office\Office16\OSPP.VBS' /dstatus
    #license name from /dstatus
    $o365 = "Office16O365ProPlusR_Subscription1 edition"
    #loop till the end of the array searching for the $o365 string 
    for ($i = 0; $i -lt $license.Length; $i++) {
        if ($license[$i] -match $o365) {
            $i += 7
            #jumping seven lines to get to the product key line in the array
            $keyline = $license[$i]
            #extra step
            $prodkey = $keyline.substring($keyline.length – 5, 5)
            #getting the last 5 characters of the line (prodkey)
        } 
    }
    #removing the key from the workstation 
    cscript 'C:\Program Files (x86)\Microsoft Office\Office16\OSPP.VBS' /unpkey:$prodkey
    

    End result was:

    Uninstalling product key for: Office 16, Office16O365ProPlusR_Subscription1 edition

    If someone wants the code and import it into PDQ Inventory as a Tool, I have sent it to support@pdq.com. Maybe they can attach it in the post? Doesn't look like I have that option...

    Regards, Martin

    0
    Comment actions Permalink
  • Colby Bouma

    Awesome, I'm glad you were able to figure it out! Unfortunately, the only files that can be attached to posts are images. If you want to share the XML file of the Tool you created, I recommend uploading it to something like Pastebin or gist.github.com.

    0
    Comment actions Permalink
  • Martin Timmelstad

    If intereted file can be downloaded here: Reset Office 365 Key on Client

    0
    Comment actions Permalink

Please sign in to leave a comment.