Like many small and medium sized companies the temptation to move to the cloud for services such as Exchange, Lync & SharePoint aka Office 365, makes both financial and resourcing sense. Given that the company I work for had decided to make the move I was tasked with the upgrade process of Office 2010 to the Office 2013/365 click to run version.

My initial though was to use a PowerShell script calling WMI to find the MSIExec, such as;

Get-WmiObject -Class Win32_product | Where-Object { $ -like “Microsoft Office Professional Plus 2010” }

I would then use the returned Identifying number combined with MSIExec switches to uninstall the product, however Office 2010 creates multiple uninstall command lines for each of its individual products.

With that option ruled out I was now on to using the Office setup.exe installer combined with customised XML to remove the product, which in theory is the easiest thing to do as the product will in 99% of cases remove Office without fault. In this scenario you use the following command (assuming you are using Pro Plus) : setup.exe /uninstall  ProPlus /config “path-to-xml”

My XML consists of the following:

<Configuration Product=”ProPlus”>
<Display Level=”none” CompletionNotice=”no” SuppressModal=”yes” AcceptEula=”yes” />
<Setting Id=”SETUP_REBOOT” Value=”Never” />

The only issue I had with this method of uninstalling the product was the 1% rule where Office would simply refuse to uninstall. Microsoft provide a VBScript for such instances ( and again I thought this would be a simple process of calling the VBScript from within a PowerShell script deployed by SCCM.

I added lines to run CScript and call the OffScrub10.vbs script but this resulted in the following error in the output log – Insufficient registry access permissions – exiting. So after many attempts I found that the most simple way to allow the script to run without compromising the security of your estate by lowering UAC settings is to copy the CScript.exe, rename it to CScript-Admin.exe and set the exe to run with administrative rights via the registry:

REG ADD “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers” /v $CSCriptLocation /t REG_SZ /d “RUNASADMIN” /f

After putting all of these steps together and also allowing for the removal of the Lync 2010 client, I created the following PowerShell script to remove your Office 2010 installation and also remove all email profiles from the local machine to avoid any PRF deployment issues when moving from your on-premise Exchange to Office 365. Simply put this script into your “Run Another Program First” section of your Office click to run installer in SCCM and automate the full removal and install of your new Office software.

Update – 20/2/2015 – Added 32/64 bit detection. Note you will need to copy the CScript.exe from both platforms and rename accordingly.

Script Download Link –

Update – Microsoft appear to have pulled the OffScrub10.vbs script from their site. I have uploaded a copy to the Microsoft Script Library page in the above link.


  Created with:  SAPIEN Technologies, Inc., PowerShell Studio 2014 v4.1.74
  Created on:    16/02/2015 12:30
  Created by:    Maurice Daly
  Office 2010 & Lync 2010 Clean Up Script. Use at your own risk.
# Office 2010 Uninstall Files
# Check if Lync 2010 is installed
$Lync2010Installed = Get-WmiObject -Class Win32_product | Where-Object { $ -like "Microsoft Lync 2010*" }
# Uninstall Lync 2010 if detected
If ($Lync2010Installed -ne $null)
 $LyncArgs = "/X" + $Lync2010Installed.IdentifyingNumber + " /passive"
 Start-Process msiexec.exe -ArgumentList $LyncArgs -Wait
# Copy Office 2010 tools to Windows Temp
Get-ChildItem -Path $Office2010Tools | Copy-Item -Destination "C:\Windows\Temp"
# CScript location variable
If ((Test-Path -Path "C:\Program Files (x86)") -eq $true)
 $CSCriptLocation = "C:\Windows\Temp\cscript-admin-64.exe"
 $OSVersion = "64Bit"
 $CSCriptLocation = "C:\Windows\Temp\cscript-admin-32.exe"
 $OSVersion = "32Bit"
# Elevate CScript-Admin executionable file for Office 2010 scrub
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v $CSCriptLocation /t REG_SZ /d "RUNASADMIN" /f
# Uninstall Office 2010 using MS OffScrub10.vbs
$OfficeScrubArgs = " ProPlus /Bypass1 /NoCancel"
If ($OSVersion -eq "64Bit")
 $OfficeScrubCommand = "cmd /C C:\Windows\Temp\cscript-admin-64.exe \\YOURSERVER\YOURSHARE\YOURDIRECTORY\Office2010-Uninstall\OffScrub10.vbs $OfficeScrubArgs"
 $OfficeScrubCommand = "cmd /C C:\Windows\Temp\cscript-admin-32.exe \\YOURSERVER\YOURSHARE\YOURDIRECTORY\OffScrub10.vbs $OfficeScrubArgs"
Invoke-Expression $OfficeScrubCommand
# Outlook Registry Path
$OutlookReg = "\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
# Clean Outlook Profiles
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
$UserSIDS = Get-ChildItem -Path HKU:\ | Split-Path -Leaf
foreach ($SID in $UserSIDS)
 $Profile = "HKU:\" + $SID + $OutlookReg
 $ProfileExists = Test-Path -Path $Profile
 if ($ProfileExists -eq $true)
  Remove-Item -Path $Profile -Recurse -Force
Remove-PSDrive -Name HKU
<# Un-comment this section to also clear OST & PST locations
$UserDirectories = Get-ChildItem -Path "C:\Users" | Where-Object { $_.PSIsContainer } | Select-Object FullName
$OutlookLocalAppData = "\AppData\Local\Microsoft\Outlook"
$OutlookRoamingAppData = "\AppData\Roaming\Microsoft\Outlook"
foreach ($User in $UserDirectories.FullName)
 if ((Test-Path -Path (Join-Path $User $OutlookLocalAppData)) -eq $true)
  Remove-Item -Path (Join-Path $User $OutlookLocalAppData) -Recurse -Force
 if ((Test-Path -Path (Join-Path $User $OutlookRoamingAppData)) -eq $true)
  Remove-Item -Path (Join-Path $User $OutlookRoamingAppData) -Recurse -Force



There are no comments.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.