Stop-Process -Name "WinWord","Excel","PowerPnt","OneNote","MsPub","MSAccess","InfoPath","Groove","OutLook","Lync","OfficeClickToRun","OfficeOnDemand","OfficeC2rClient","AppvshNotify","FirstRun","Setup","IntegratedOffIce","Integrator","Communicator","MSOSync","OneNoteM","IExplore","Mavinject32","Werfault","PerfBoost","RoamingOffice","MSIExec","OSE" -CO:$False -EA SI -F
Move-Item "$env:LocalAppData\Microsoft\Outlook" C:\ -FO -EA SI -EV ProcessError;
If ($ProcessError) { CMD /C START /MAX "" "$env:LocalAppData\Microsoft" }
$RegKey = "\SOFTWARE\Microsoft\Office"
Reg Export "HKEY_LOCAL_MACHINE$RegKey" "C:\Office.reg"
Remove-Item "HKCU:$RegKey" -CO:$False -FO -R -EA SI -EV ProcessError;
If ($ProcessError) { Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit" "LastKey" Computer\HKEY_CURRENT_USER\Software\Microsoft | regedit.exe -m }
Set-ExecutionPolicy RemoteSigned -CO:$False
Invoke-RestMethod -Uri "https://download.microsoft.com/download/e/1/b/e1bbdc16-fad4-4aa2-a309-2ba3cae8d424/OLicenseCleanup.zip" -OutFile "OLC.zip"
Invoke-RestMethod -Uri "https://download.microsoft.com/download/f/8/7/f8745d3b-49ad-4eac-b49a-2fa60b929e7d/signoutofwamaccounts.zip" -OutFile "WAM.zip"
Invoke-RestMethod -Uri "https://download.microsoft.com/download/8/e/f/8ef13ae0-6aa8-48a2-8697-5b1711134730/WPJCleanUp.zip" -OutFile "WPJ.zip"
Expand-Archive OLC.zip -DestinationPath OLC -F
Expand-Archive WAM.zip -DestinationPath OLC\WAM -F
Expand-Archive WPJ.zip -DestinationPath OLC\WAM\WPJ -F
CD OLC\OLicenseCleanup
Start-Process "OLicenseCleanup.VBS" -Wait
CD..
CD WAM
.\signoutofwamaccounts.ps1 -Wait
CD WPJ\WPJCleanUp\WPJCleanUp
.\WPJCleanUp.cmd -Wait
Cmd /c "for /F "tokens=1,2 delims= " %G in ('cmdkey /list ^| findstr Target') do cmdkey /delete %H"
Control /name Microsoft.CredentialManager
Start Outlook.exe /cleanroamedprefs