Last active
May 7, 2025 17:13
-
-
Save mark05e/2ea9ed60ce405cf8d5d4c3635ba357ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RESET OFFICE ACTIVATION STATE | |
# https://docs.microsoft.com/en-us/office/troubleshoot/activation/reset-office-365-proplus-activation-state | |
# by: https://gist.github.com/mark05e | |
# | |
# Lines to look out for: | |
# > The four steps above can be automated using OLicenseCleanup.vbs. Simply download and run the script with elevated privileges. | |
# > To clear all WAM accounts associated with Office on the device, download and run the signoutofwamaccounts.ps1 script with elevated privileges. | |
# > To automate WPJ removal, download WPJCleanUp.zip, extract the folder, and run WPJCleanUp.cmd. | |
$Urls = @( | |
"https://download.microsoft.com/download/e/1/b/e1bbdc16-fad4-4aa2-a309-2ba3cae8d424/OLicenseCleanup.zip", | |
"https://download.microsoft.com/download/f/8/7/f8745d3b-49ad-4eac-b49a-2fa60b929e7d/signoutofwamaccounts.zip", | |
"https://download.microsoft.com/download/8/e/f/8ef13ae0-6aa8-48a2-8697-5b1711134730/WPJCleanUp.zip" | |
) | |
$BaseExtractPath = "C:\TempPath\o365reset\" | |
# create folder anyway | |
New-Item -ItemType Directory -Path $BaseExtractPath -Force | |
# download and extract files | |
foreach ($Url in $Urls) { | |
$DownloadZipFile = $BaseExtractPath + $(Split-Path -Path $Url -Leaf) | |
$ExtractPath = $BaseExtractPath | |
write-host "Downloading: $Url" | |
Invoke-WebRequest -Uri $Url -OutFile $DownloadZipFile | |
$ExtractShell = New-Object -ComObject Shell.Application | |
$ExtractFiles = $ExtractShell.Namespace($DownloadZipFile).Items() | |
$ExtractShell.NameSpace($ExtractPath).CopyHere($ExtractFiles) | |
} | |
# check if the files exist after extract | |
write-host "Test OLicenseCleanup.vbs: " -nonewline; Test-Path $BaseExtractPath\OLicenseCleanup.vbs | |
write-host "Test signoutofwamaccounts.ps1: " -nonewline; Test-Path $BaseExtractPath\signoutofwamaccounts.ps1 | |
write-host "Test WPJCleanUp.cmd: " -nonewline; Test-Path $BaseExtractPath\WPJCleanUp\WPJCleanUp\WPJCleanUp.cmd | |
# execute each script | |
write-host "Execute OLicenseCleanup.vbs: " | |
Start-Process -Filepath cscript.exe -ArgumentList $BaseExtractPath\OLicenseCleanup.vbs -NoNewWindow -PassThru | |
Start-Sleep 3 | |
write-host "Execute signoutofwamaccounts.ps1: " | |
Start-Process -Filepath powershell.exe -ArgumentList $BaseExtractPath\signoutofwamaccounts.ps1 -NoNewWindow -PassThru | |
Start-Sleep 3 | |
write-host "Execute WPJCleanUp.cmd: " | |
Start-Process $BaseExtractPath\WPJCleanUp\WPJCleanUp\WPJCleanUp.cmd -NoNewWindow -PassThru | |
Start-Sleep 3 |
@Pat28K just fixed it. Needed to launch vbs file using cscript.
@mark05e Awesome, thank you for this script and for the help!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Everything works great for me, up until it gets to the Start-Process part of the scripts, then I get an error on both that say: This command cannot be run due to the error: %1 is not a valid Win32 application. Am I missing something really basic?