A couple of my clients have recently asked me to remove all instances of Office from 2010 through 2016 to deploy Office 365. As usual, Microsoft is unpredictable on what versions will be supported together. Today, Office 365 cannot be installed if any version of Office is installed on a machine, to include Visio and Projects.
If your organization is supporting multiple versions of Office, remember to put the necessary exclusions in SCCM so if any user or machine receives Office 365; the older versions of office do not get installed.
To remove any version of Office, Project, or Visio from any Windows OS, I choose to leverage the PSAppDeploy. It has a lot of cool features to prompt message dialogs. Dialogs can even be prompted with applications if you leverage the ServiceUI.exe from the MDT. Google it, you will find it vary helpful.
Note: You will not need the office source to uninstall. This helps reduce the footprint in SCCM distribution points and on the desktops.
What is needed:
- Download PSAppDeploy if you don’t have it
- Read documentation
- You may find another way that may be easier
- Setup defaults
- Logging
- Install Logo’s
- Download all the office scrubs fix it’s and extract the VBS for each. There are scrubs for each version of Office and, in some cases, scrubs based on the OS as well. Make sure you download them all that you want to
- A little PowerShell scripting experience
- Read documentation
Setup
- Once you have the scub scripts extracted. Separate and organize them in a folder structure in the files directory within the PSAppDeploy Toolkit.
- Identify if a message is going to be needed prior to the remove. In this example I am using a 5 minute countdown if any of the office products are open.
- Prepare to remove different scenerios
- Office 2013 with Project 2010
- Office 2010 with Visio 2016 and Project 2013
- ..
Notes
- In this example WMI is called to see if there is any office products installed, if so remove them based on the version of Office and the operating system. Checking WMI does take longer than checking Registry, but it is easier to go this route. We don’t have to check for multiple GUIDS. The last action will be to install O365.
- You may have to edit the officescrub2010.vbs to not return exit code of 3010.
- Make sure you reboot after install.
- The below script is only the install portion. If you copy \ paste, be sure that the source paths for the command lines are modified to match your PSAppDeploy folder structure.
- Validate prior to deploying.
Script
If ($deploymentType -ine ‘Uninstall’)
{
##*===============================================
##* PRE-INSTALLATION
##*===============================================
[string]$installPhase = ‘Pre-Installation’
Show-InstallationWelcome -CloseApps ‘Outlook=Microsoft Outlook,iexplore=Internet Explorer,winword=Microsoft Office Word,excel=Microsoft Office Excel,VISIO=Visio,ONENOTE=OneNote,POWERPNT=Microsoft PowerPoint,MSPUB=Microsoft Publisher’ -CloseAppsCountdown 300
## <Perform Pre-Installation tasks here>
######## checking wmi for installed office #######################
#Office 2016
$officePro2016 = Get-WmiObject -Class Win32_Product | Where { $_.Name -like “*Microsoft Office Pro*Plus*2016” } | select -ExpandProperty ‘Name’
Write-Log -Message “$officePro2016 is installed” -Source ‘Office version’ -LogType ‘Legacy’
$officeSTD2016 = Get-WmiObject -Class Win32_Product | Where { $_.Name -like “*Microsoft Office Standard*2016” } | select -ExpandProperty ‘Name’
Write-Log -Message “$officeSTD2016 is installed” -Source ‘Office version’ -LogType ‘Legacy’
#Project 2016
$officeProj2016 = Get-WmiObject -Class Win32_Product | Where { $_.Name -like “*Microsoft *Project*2016” } | select -ExpandProperty ‘Name’
Write-Log -Message “$officeProj2016 is installed” -Source ‘Office Project version’ -LogType ‘Legacy’
#Visio 2016
$officevisio2016 = Get-WmiObject -Class Win32_Product | Where { $_.Name -like “*Microsoft *Visio*2016” } | select -ExpandProperty ‘Name’
Write-Log -Message “$officevisio2016 is installed” -Source ‘Office Visio version’ -LogType ‘Legacy’
#office 2010
$officePro2010 = Get-WmiObject -Class Win32_Product | Where { $_.Name -like “*Microsoft Office Pro*Plus*2010” } | select -ExpandProperty ‘Name’
Write-Log -Message “$officePro2010 is installed” -Source ‘Office version’ -LogType ‘Legacy’
$officeSTD2010 = Get-WmiObject -Class Win32_Product | Where { $_.Name -like “*Microsoft Office Standard*2010” } | select -ExpandProperty ‘Name’
Write-Log -Message “$officeSTD2010 is installed” -Source ‘Office version’ -LogType ‘Legacy’
#Project 2010
$officeProj2010 = Get-WmiObject -Class Win32_Product | Where { $_.Name -like “*Microsoft *Project*2010” } | select -ExpandProperty ‘Name’
Write-Log -Message “$officeProj2010 is installed” -Source ‘Office version’ -LogType ‘Legacy’
#Visio 2010
$officeVisio2010 = Get-WmiObject -Class Win32_Product | Where { $_.Name -like “*Microsoft *Visio*2010” } | select -ExpandProperty ‘Name’
Write-Log -Message “$officeVisio2010g is installed” -Source ‘Office version’ -LogType ‘Legacy’
#Office 2013
$officePRO2013 = Get-WmiObject -Class Win32_Product | Where { $_.Name -like “*Microsoft Office Pro*Plus*2013” } | select -ExpandProperty ‘Name’
Write-Log -Message “$officePRO2013 is installed” -Source ‘Office version’ -LogType ‘Legacy’
$officeSTD2013 = Get-WmiObject -Class Win32_Product | Where { $_.Name -like “*Microsoft Office Standard*2013” } | select -ExpandProperty ‘Name’
Write-Log -Message “$officeSTD2013 is installed” -Source ‘Office version’ -LogType ‘Legacy’
#Project 2013
$officeProj2013 = Get-WmiObject -Class Win32_Product | Where { $_.Name -like “*Microsoft *Project*2013” } | select -ExpandProperty ‘Name’
Write-Log -Message “$officeProj2013 is installed” -Source ‘Office version’ -LogType ‘Legacy’
#Visio 2013
$officeVisio2013 = Get-WmiObject -Class Win32_Product | Where { $_.Name -like “*Microsoft *Visio*2013” } | select -ExpandProperty ‘Name’
Write-Log -Message “$officeVisio2013 is installed” -Source ‘Office version’ -LogType ‘Legacy’
##*===============================================
##* INSTALLATION
##*===============================================
[string]$installPhase = ‘Installation’
Show-InstallationProgress -StatusMessage ‘Upgrading to Office 365. This will take several minutes and may require a reboot. Please wait…DO NOT FORCE A REBOOT DURING THIS PROCESS! Doing so may damage your OS.’
## <Perform Installation tasks here>
################ Get OS and Platform #######################
write-log -message $envOSName -source ‘getOS’ -logtype ‘CMTrace’
################ Check Office Version ######################
####### remove office 2010 #############
If ($officePro2010 -or $officeSTD2010 -or $officeVisio2010 -or $officeProj2010)
{
Write-Log -Message “Removing installed version of Office.” -Source ‘Removing Office’ -LogType ‘Legacy’
execute-process -FilePath “CScript.Exe” -Arguments “$dirfiles/2010Scrub/OffScrub10.vbs ALL /Q /NoCancel /BYPASS 1 /Log c:\windows\installlogs\Office2010_VI_Uninstall.log” -WaitForMsiExec
}
####### remove office 2013 #############
# remove office 2013 on Win 7
If ($envOSName -like ‘*Windows 7*’)
{
If ($officePRO2013 -or $officeSTD2013 -or $officeProj2013 -or $officeVisio2013)
{
Write-Log -Message “Removing installed version of Office.” -Source ‘Removing Office’ -LogType ‘Legacy’
execute-process -FilePath “CScript.Exe” -Arguments “$dirfiles/2013-2016Scrub/Win7/OffScrub_O15msi.vbs ALL /Q /NoCancel /BYPASS 1 /Log c:\windows\installlogs\Office2013_VI_Uninstall.log” -WaitForMsiExec
}
}
#remove office 2013 on Win 8
If ($envOSName -like ‘*Windows 8*’)
{
If ($officePRO2013 -or $officeSTD2013 -or $officeProj2013 -or $officeVisio2013)
{
Write-Log -Message “Removing installed version of Office.” -Source ‘Removing Office’ -LogType ‘Legacy’
execute-process -FilePath “CScript.Exe” -Arguments “$dirfiles/2013-2016Scrub/Win8/OffScrub_O15msi.vbs ALL /Q /NoCancel /BYPASS 1 /Log c:\windows\installlogs\Office2013_VI_Uninstall.log” -WaitForMsiExec
}
}
#remove office 2013 on Win 10
If ($envOSName -like ‘*Windows 10*’)
{
If ($officePRO2013 -or $officeSTD2013 -or $officeProj2013 -or $officeVisio2013)
{
Write-Log -Message “Removing installed version of Office.” -Source ‘Removing Office’ -LogType ‘Legacy’
execute-process -FilePath “CScript.Exe” -Arguments “$dirfiles/2013-2016Scrub/Win10/OffScrub_O15msi.vbs ALL /Q /NoCancel /BYPASS 1 /Log c:\windows\installlogs\Office2013_VI_Uninstall.log” -WaitForMsiExec
}
}
####### remove office 2016 Pro #############
# remove on Win 7
If ($envOSName -like ‘*Windows 7*’)
{
If ($officePro2016 -or $officeSTD2016 -or $officeProj2016 -or $officevisio2016)
{
Write-Log -Message “Removing installed version of Office.” -Source ‘Removing Office’ -LogType ‘Legacy’
execute-process -FilePath “CScript.Exe” -Arguments “$dirfiles/2013-2016Scrub/Win7/OffScrub_O16msi.vbs ALL /Q /NoCancel /BYPASS 1 /Log c:\windows\installlogs\Office2016_VI_Uninstall.log” -WaitForMsiExec
}
}
#remove on Win 8
If ($envOSName -like ‘*Windows 8*’)
{
If ($officePro2016 -or $officeSTD2016 -or $officeProj2016 -or $officevisio2016)
{
Write-Log -Message “Removing installed version of Office.” -Source ‘Removing Office’ -LogType ‘Legacy’
execute-process -FilePath “CScript.Exe” -Arguments “$dirfiles/2013-2016Scrub/Win8/OffScrub_O16msi.vbs ALL /Q /NoCancel /BYPASS 1 /Log c:\windows\installlogs\Office2016_VI_Uninstall.log” -WaitForMsiExec
}
}
# Remove on win 10
If ($envOSName -like ‘*Windows 10*’)
{
If ($officePro2016 -or $officeSTD2016 -or $officeProj2016 -or $officevisio2016)
{
Write-Log -Message “Removing installed version of Office.” -Source ‘Removing Office’ -LogType ‘Legacy’
execute-process -FilePath “CScript.Exe” -Arguments “$dirfiles/2013-2016Scrub/Win10/OffScrub_O16msi.vbs ALL /Q /NoCancel /BYPASS 1 /Log c:\windows\installlogs\Office2016_VI_Uninstall.log” -WaitForMsiExec
}
}
execute-process -path “$dirfiles/O365/setup.exe” -arguments “/configure O365ProPlusRetail.xml”
##*===============================================
##* POST-INSTALLATION
##*===============================================
[string]$installPhase = ‘Post-Installation’
## <Perform Post-Installation tasks here>
## Display a message at the end of the install
If (-not $useDefaultMsi) { }
}
ElseIf ($deploymentType -ieq ‘Uninstall’)
{
##*===============================================
##* PRE-UNINSTALLATION
##*===============================================
[string]$installPhase = ‘Pre-Uninstallation’
## Show Welcome Message, close Internet Explorer with a 60 second countdown before automatically closing
#Show-InstallationWelcome -CloseApps ‘iexplore’ -CloseAppsCountdown 60
Show-InstallationWelcome -CloseApps ‘Outlook=Microsoft Outlook,iexplore=Internet Explorer,winword=Microsoft Office Word,excel=Microsoft Office Excel,VISIO=Visio,ONENOTE=OneNote,POWERPNT=Microsoft PowerPoint,MSPUB=Microsoft Publisher’ -CloseAppsCountdown 300
## Show Progress Message (with the default message)
Show-InstallationProgress -StatusMessage ‘Removing Office May require a reboot. Please wait…DO NOT FORCE A REBOOT DURING THIS PROCESS! Doing so may damage your OS.’
execute-process -path “$dirfiles/O365/setup.exe” -arguments “/configure `”$dirfiles/O365/uninstallO365.xml`””
If (-not $useDefaultMsi) { }
}
ElseIf ($deploymentType -ieq ‘Uninstall’)
{
## <Perform Pre-Uninstallation tasks here>
##*===============================================
##* UNINSTALLATION
##*===============================================
[string]$installPhase = ‘Uninstallation’
##*===============================================
##* POST-UNINSTALLATION
##*===============================================
[string]$installPhase = ‘Post-Uninstallation’
## <Perform Post-Uninstallation tasks here>
}
##*===============================================
##* END SCRIPT BODY
##*===============================================