Office 365 (2016) click to run

Hi,
I would like to use the toolkit to remove Office 2010 and deploy Office 2016 with the click-to-run scripts. I already have the uninstall part figured out from the help file, but need assistance with the 2016 part.

I have the shares(test and prod) and XML files ready. It deploys via \server\share\setup.exe /configure office2012-prod.xml. It’s a silent install with parameters for what products to install, update path, etc.

Is there a way to launch a commandline install while keeping the pop-up box in place? Also need a post-install removal of OneDrive, which may require commandline as well.

Thanks, John

What popup box are you talking about? The O365 installation boxes, PSApp dialog boxes or Command prompt window? Not sure why you would want to show the Command Prompt window when you have the option of the other two. Also why post-install removal of OneDrive? You should be able to use <ExcludeApp ID=“Groove” /> to keep it from installing.

Below is the script I use that I can either push out via SCCM or make it available for a user to install via the App Portal. My support guys also use this for manual installs when needed. It does show the dialog boxes for PSApp toolkit and the O365 windows during install when not doing a required install.

This was created for migration to On-Premise to O365 so it’s built around removing Office version 2003 and up. We also have situations where we needed language packs or having the install configured in shared licensing mode so I added switches that would call different configuration files based on switch.

Dunno if this will help you out on what you’re wanting.

Edit: If you’re really wanting a post-install removal of OneDrive then you should be able to add a setup.exe /configure OneDriveRemoval.xml in the Post-Install section. You’d need to craft an xml file with <ExcludeApp ID=“Groove” /> in it. Not 100% on this but in theory should work.

<#
.SYNOPSIS
This script performs the installation or uninstallation of an application(s).
.DESCRIPTION
The script is provided as a template to perform an install or uninstall of an application(s).
The script either performs an “Install” deployment type or an “Uninstall” deployment type.
The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.
The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
.PARAMETER DeploymentType
The type of deployment to perform. Default is: Install.
.PARAMETER DeployMode
Specifies whether the installation should be run in Interactive, Silent, or NonInteractive mode. Default is: Interactive. Options: Interactive = Shows dialogs, Silent = No dialogs, NonInteractive = Very silent, i.e. no blocking apps. NonInteractive mode is automatically set if it is detected that the process is not user interactive.
.PARAMETER AllowRebootPassThru
Allows the 3010 return code (requires restart) to be passed back to the parent process (e.g. SCCM) if detected from an installation. If 3010 is passed back to SCCM, a reboot prompt will be triggered.
.PARAMETER TerminalServerMode
Changes to “user install mode” and back to “user execute mode” for installing/uninstalling applications for Remote Destkop Session Hosts/Citrix servers.
.PARAMETER DisableLogging
Disables logging to file for the script. Default is: $false.
.EXAMPLE
Deploy-Application.ps1
.EXAMPLE
Deploy-Application.ps1 -DeployMode ‘Silent’
.EXAMPLE
Deploy-Application.ps1 -AllowRebootPassThru -AllowDefer
.EXAMPLE
Deploy-Application.ps1 -DeploymentType Uninstall
.NOTES
Toolkit Exit Code Ranges:
60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
.LINK
http://psappdeploytoolkit.codeplex.com
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory=$false)]
[ValidateSet(‘Install’,‘Uninstall’)]
[string]$DeploymentType = ‘Install’,
[Parameter(Mandatory=$false)]
[ValidateSet(‘Interactive’,‘Silent’,‘NonInteractive’)]
[string]$DeployMode = ‘Interactive’,
[Parameter(Mandatory=$false)]
[switch]$AllowRebootPassThru = $false,
[Parameter(Mandatory=$false)]
[switch]$TerminalServerMode = $false,
[Parameter(Mandatory=$false)]
[switch]$DisableLogging = $false,
[switch]$IsSharedPC = $false,
[Parameter(Mandatory=$false)]
[ValidateSet(‘ENUS’,‘ALL’)]
[string]$Language = ‘ENUS’

)

Try {
## Set the script execution policy for this process
Try { Set-ExecutionPolicy -ExecutionPolicy ‘ByPass’ -Scope ‘Process’ -Force -ErrorAction ‘Stop’ } Catch {}

##*===============================================
##* VARIABLE DECLARATION
##*===============================================
## Variables: Application
[string]$appVendor = 'Microsoft'
[string]$appName = 'Office 365 ProPlus'
[string]$appVersion = '16.0.6001.1061'
[string]$appArch = 'x86'
[string]$appLang = 'EN'
[string]$appRevision = '1'
[string]$appScriptVersion = '1.1.0'
[string]$appScriptDate = ''
[string]$appScriptAuthor = ''
##*===============================================

##* Do not modify section below
#region DoNotModify

## Variables: Exit Code
[int32]$mainExitCode = 0

## Variables: Script
[string]$deployAppScriptFriendlyName = 'Deploy Application'
[version]$deployAppScriptVersion = [version]'3.6.1'
[string]$deployAppScriptDate = '03/26/2015'
[hashtable]$deployAppScriptParameters = $psBoundParameters

## Variables: Environment
[string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent

## Dot source the required App Deploy Toolkit Functions
Try {
	[string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
	If (-not (Test-Path -Path $moduleAppDeployToolkitMain -PathType Leaf)) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
	If ($DisableLogging) { . $moduleAppDeployToolkitMain -DisableLogging } Else { . $moduleAppDeployToolkitMain }
}
Catch {
	[int32]$mainExitCode = 60008
	Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: <code>n$($_.Exception.Message)</code>n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
	Exit $mainExitCode
}

#endregion
##* Do not modify section above
##*===============================================
##* END VARIABLE DECLARATION
##*===============================================

#  Set the initial Office folder
[string] $dirOffice = Join-Path -Path "$envProgramFilesX86" -ChildPath "Microsoft Office"
[string] $dirOfficeC2R = Join-Path -Path "$envProgramFiles" -ChildPath "Microsoft Office 15"
[string] $dirOfficeX64 = Join-Path -Path "$envProgramFiles" -ChildPath "Microsoft Office"
[string] $dirOfficeC2RX86 = Join-Path -Path "$envProgramFilesX86" -ChildPath "Microsoft Office 15"	

If ($deploymentType -ine 'Uninstall') {
	##*===============================================
	##* PRE-INSTALLATION
	##*===============================================
	[string]$installPhase = 'Pre-Installation'
	
	## Show Welcome Message, close IE and all office apps, verify there is enough disk space to complete the install, and persist the prompt
	Show-InstallationWelcome -CloseApps 'officeclicktorun,ose,osppsvc,sppsvc,msoia,excel,groove,onenote,infopath,onenote,outlook,mspub,powerpnt,winword,winproj,visio,iexplore' -Silent -CheckDiskSpace -PersistPrompt
	
	## Show Progress Message 
	Show-InstallationProgress -StatusMessage "Office 365 Installation in Progress...The Installation may take up to 45 minutes to complete." -TopMost $False 
	
	## Display Pre-Install cleanup status
		Show-InstallationProgress -StatusMessage "Performing Pre-Install cleanup. Removing Prior Office Versions... This may take some time. Please wait..."
		
		# Remove any previous version of Office (if required)
		[string[]]$officeExecutables = 'excel.exe', 'groove.exe', 'infopath.exe', 'onenote.exe', 'outlook.exe', 'mspub.exe', 'powerpnt.exe', 'winword.exe'
		ForEach ($officeExecutable in $officeExecutables) {
			If (Test-Path -Path (Join-Path -Path $dirOffice -ChildPath "Office11\$officeExecutable") -PathType Leaf) {
				Write-Log -Message 'Microsoft Office 2003 was detected. Will be uninstalled.' -Source $deployAppScriptFriendlyName
				Execute-Process -Path 'cscript.exe' -Parameters "<code>&quot;$dirSupportFiles\OffScrub03.vbs</code>" ALL /S /Q /NoCancel /Bypass 1" -WindowStyle Hidden -IgnoreExitCodes '1,2,3,16,42'
				Break
			}
		}
		ForEach ($officeExecutable in $officeExecutables) {
			If (Test-Path -Path (Join-Path -Path $dirOffice -ChildPath "Office12\$officeExecutable") -PathType Leaf) {
				Write-Log -Message 'Microsoft Office 2007 was detected. Will be uninstalled.' -Source $deployAppScriptFriendlyName
				Execute-Process -Path 'cscript.exe' -Parameters "<code>&quot;$dirSupportFiles\OffScrub07.vbs</code>" ProPlus,Pro,Standard /S /Q /NoCancel /Bypass 1" -WindowStyle Hidden -IgnoreExitCodes '1,2,3,16,42'
				Break
			}
		}
		ForEach ($officeExecutable in $officeExecutables) {
			If (Test-Path -Path (Join-Path -Path $dirOffice -ChildPath "Office14\$officeExecutable") -PathType Leaf) {
				Write-Log -Message 'Microsoft Office 2010 was detected. Will be uninstalled.' -Source $deployAppScriptFriendlyName
				Execute-Process -Path "cscript.exe" -Parameters "<code>&quot;$dirSupportFiles\OffScrub10.vbs</code>" ProPlus,Pro,Standard,SINGLEIMAGE /S /Q /NoCancel /Bypass 1" -WindowStyle Hidden -IgnoreExitCodes '1,2,3,16,42'
				Break
			}
		}
		ForEach ($officeExecutable in $officeExecutables) {
			If (Test-Path -Path (Join-Path -Path $dirOffice -ChildPath "Office15\$officeExecutable") -PathType Leaf) {
				Write-Log -Message 'Microsoft Office 2013 was detected. Will be uninstalled.' -Source $deployAppScriptFriendlyName
				Execute-Process -Path "cscript.exe" -Parameters "<code>&quot;$dirSupportFiles\OffScrub_O15msi.vbs</code>" ProPlus,Pro,Standard,SINGLEIMAGE /S /Q /NoCancel /Bypass 1" -WindowStyle Hidden -IgnoreExitCodes '1,2,3,16,42'
				Break
			}
		}
	    ForEach ($officeExecutable in $officeExecutables) {
			If (Test-Path -Path (Join-Path -Path $dirOfficeC2R -ChildPath "root\Office15\$officeExecutable") -PathType Leaf) {
				Write-Log -Message 'Microsoft Office 2013 C2R was detected. Will be uninstalled.' -Source $deployAppScriptFriendlyName
				Execute-Process -Path "cscript.exe" -Parameters "<code>&quot;$dirSupportFiles\OffScrub_O15c2r.vbs</code>" ALL /S /Q /NoCancel /Bypass 1" -WindowStyle Hidden -IgnoreExitCodes '1,2,3,42,34,67'
				Break
			}
		}
		ForEach ($officeExecutable in $officeExecutables) {
			If (Test-Path -Path (Join-Path -Path $dirOfficeX64 -ChildPath "Office14\$officeExecutable") -PathType Leaf) {
				Write-Log -Message 'Microsoft Office 2010 was detected. Will be uninstalled.' -Source $deployAppScriptFriendlyName
				Execute-Process -Path "cscript.exe" -Parameters "<code>&quot;$dirSupportFiles\OffScrub10.vbs</code>" ProPlus,Pro,Standard,SINGLEIMAGE /S /Q /NoCancel /Bypass 1" -WindowStyle Hidden -IgnoreExitCodes '1,2,3,16,42'
				Break
			}
		}
		ForEach ($officeExecutable in $officeExecutables) {
			If (Test-Path -Path (Join-Path -Path $dirOfficeX64 -ChildPath "Office15\$officeExecutable") -PathType Leaf) {
				Write-Log -Message 'Microsoft Office 2013 was detected. Will be uninstalled.' -Source $deployAppScriptFriendlyName
				Execute-Process -Path "cscript.exe" -Parameters "<code>&quot;$dirSupportFiles\OffScrub_O15msi.vbs</code>" ProPlus,Pro,Standard,SINGLEIMAGE /S /Q /NoCancel /Bypass 1" -WindowStyle Hidden -IgnoreExitCodes '1,2,3,16,42'
				Break
			}
		}
	   ForEach ($officeExecutable in $officeExecutables) {
			If (Test-Path -Path (Join-Path -Path $dirOfficeC2RX86 -ChildPath "root\Office15\$officeExecutable") -PathType Leaf) {
				Write-Log -Message 'Microsoft Office 2013 C2R was detected. Will be uninstalled.' -Source $deployAppScriptFriendlyName
				Execute-Process -Path "cscript.exe" -Parameters "<code>&quot;$dirSupportFiles\OffScrub_O15c2r.vbs</code>" ALL /S /Q /NoCancel /Bypass 1" -WindowStyle Hidden -IgnoreExitCodes '1,2,3,42,34,67'
				Break
			}
		}
	
	
	##*===============================================
	##* INSTALLATION 
	##*===============================================
	[string]$installPhase = 'Installation'
	
	## Handle Zero-Config MSI Installations
	If ($useDefaultMsi) { Execute-MSI -Action 'Install' -Path $defaultMsiFile }
	
	## &lt;Perform Installation tasks here&gt;
	
	## Check if Installing in Shared Computer Mode
	If (-not $IsSharedPC) {
		If ($Language -eq 'ENUS') {
			Show-InstallationProgress -StatusMessage 'Installing Office 365 ProPlus. This may take some time. Please wait...' -TopMost $True
			Execute-Process -Path "$dirFiles\Setup.exe" -Parameters "/CONFIGURE ProPlus32.xml"
		}
		If ($Language -eq 'ALL') {
			Show-InstallationProgress -StatusMessage 'Installing Office 365 ProPlus. This may take some time. Please wait...' -TopMost $True
			Execute-Process -Path "$dirFiles\Setup.exe" -Parameters "/CONFIGURE ProPlus32_ALL.xml"
		}
	}
	 
	If ($IsSharedPC) {
		If ($Language -eq 'ENUS') {
			Show-InstallationProgress -StatusMessage 'Installing Office 365 ProPlus. This may take some time. Please wait...' -TopMost $True
			Execute-Process -Path "$dirFiles\Setup.exe" -Parameters "/CONFIGURE ProPlus32_SharedPC.xml"
		}
		If ($Language -eq 'ALL') {
			Show-InstallationProgress -StatusMessage 'Installing Office 365 ProPlus. This may take some time. Please wait...' -TopMost $True
			Execute-Process -Path "$dirFiles\Setup.exe" -Parameters "/CONFIGURE ProPlus32_SharedPC_ALL.xml"
		}
	} 
	
	
	##*===============================================
	##* POST-INSTALLATION
	##*===============================================
	[string]$installPhase = 'Post-Installation'
	
	## &lt;Perform Post-Installation tasks here&gt;
	
	## Display a message at the end of the install
	## Display a message at the end of the install
	Show-InstallationPrompt -Message "Office 365 ProPlus Installation is complete." -ButtonRightText 'OK' -Icon Information -NoWait
	
}
ElseIf ($deploymentType -ieq 'Uninstall')
{
	##*===============================================
	##* PRE-UNINSTALLATION
	##*===============================================
	[string]$installPhase = 'Pre-Uninstallation'
	
	## Show Welcome Message, 
	Show-InstallationWelcome -CloseApps 'excel,groove,onenote,infopath,onenote,outlook,mspub,powerpnt,winword,winproj,visio,iexplore' -Silent
	
	## Show Progress Message (with the default message)
	Show-InstallationProgress
	
	## &lt;Perform Pre-Uninstallation tasks here&gt;
	
	
	##*===============================================
	##* UNINSTALLATION
	##*===============================================
	[string]$installPhase = 'Uninstallation'
	
	## Handle Zero-Config MSI Uninstallations
	If ($useDefaultMsi) { Execute-MSI -Action 'Uninstall' -Path $defaultMsiFile }
	
	# &lt;Perform Uninstallation tasks here&gt;
	Show-InstallationProgress -StatusMessage 'Uninstalling Office 365 ProPlus. This may take some time. Please wait...'
	Execute-Process -Path "$dirFiles\Setup.exe" -Parameters "/CONFIGURE Remove.xml"
	
	
	##*===============================================
	##* POST-UNINSTALLATION
	##*===============================================
	[string]$installPhase = 'Post-Uninstallation'
	
	## &lt;Perform Post-Uninstallation tasks here&gt;
	Show-InstallationPrompt -Message "Office 365 ProPlus uninstallation has completed. Your Computer will need to be restarted. You will recieve a prompt scheduling a restart" -ButtonRightText 'OK' -Icon Information -NoWait
	
}

##*===============================================
##* END SCRIPT BODY
##*===============================================

## Call the Exit-Script function to perform final cleanup operations
Exit-Script -ExitCode $mainExitCode

}
Catch {
[int32]$mainExitCode = 3010
[string]$mainErrorMessage = “$(Resolve-Error)”
Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
Show-DialogBox -Text $mainErrorMessage -Icon ‘Stop’
Exit-Script -ExitCode $mainExitCode
}

Hi Jason,

I know this forum is 4 weeks old but I stumbled upon it in my search to finding a way to use the deployment toolkit to install Office 365 2016. I saw your setup but I can’t seem to get mine to work. I keep receiving an error balloon stating “Installation Failed” from the taskbar. Not sure what I am missing but here is the script I developed. Can you or anyone else see where am I going wrong? I already placed all of the files for office install (ie. setup.exe and the .xml) within the same folder as the “Deploy-Application.ps1”.

<pre class=“brush: powershell; gutter: true; first-line: 1; highlight: []; html-script: false”><#
.SYNOPSIS
This script performs the installation or uninstallation of an application(s).
.DESCRIPTION
The script is provided as a template to perform an install or uninstall of an application(s).
The script either performs an “Install” deployment type or an “Uninstall” deployment type.
The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.
The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
.PARAMETER DeploymentType
The type of deployment to perform. Default is: Install.
.PARAMETER DeployMode
Specifies whether the installation should be run in Interactive, Silent, or NonInteractive mode. Default is: Interactive. Options: Interactive = Shows dialogs, Silent = No dialogs, NonInteractive = Very silent, i.e. no blocking apps. NonInteractive mode is automatically set if it is detected that the process is not user interactive.
.PARAMETER AllowRebootPassThru
Allows the 3010 return code (requires restart) to be passed back to the parent process (e.g. SCCM) if detected from an installation. If 3010 is passed back to SCCM, a reboot prompt will be triggered.
.PARAMETER TerminalServerMode
Changes to “user install mode” and back to “user execute mode” for installing/uninstalling applications for Remote Destkop Session Hosts/Citrix servers.
.PARAMETER DisableLogging
Disables logging to file for the script. Default is: $false.
.EXAMPLE
powershell.exe -Command “& { & ‘.\Deploy-Application.ps1’ -DeployMode ‘Silent’; Exit $LastExitCode }”
.EXAMPLE
powershell.exe -Command “& { & ‘.\Deploy-Application.ps1’ -AllowRebootPassThru; Exit $LastExitCode }”
.EXAMPLE
powershell.exe -Command “& { & ‘.\Deploy-Application.ps1’ -DeploymentType ‘Uninstall’; Exit $LastExitCode }”
.EXAMPLE
Deploy-Application.exe -DeploymentType “Install” -DeployMode “Silent”
.NOTES
Toolkit Exit Code Ranges:
60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
.LINK
http://psappdeploytoolkit.com
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory=$false)]
[ValidateSet(‘Install’,‘Uninstall’)]
[string]$DeploymentType = ‘Install’,
[Parameter(Mandatory=$false)]
[ValidateSet(‘Interactive’,‘Silent’,‘NonInteractive’)]
[string]$DeployMode = ‘Interactive’,
[Parameter(Mandatory=$false)]
[switch]$AllowRebootPassThru = $false,
[Parameter(Mandatory=$false)]
[switch]$TerminalServerMode = $false,
[Parameter(Mandatory=$false)]
[switch]$DisableLogging = $false
)

Try {
## Set the script execution policy for this process
Try { Set-ExecutionPolicy -ExecutionPolicy 'ByPass' -Scope 'Process' -Force -ErrorAction 'Stop' } Catch {}

##*===============================================
##* VARIABLE DECLARATION
##*===============================================
## Variables: Application
[string]$appVendor = &#039;Microsoft&#039;
[string]$appName = &#039;Office 2016&#039;
[string]$appVersion = &#039;16.0.6001.1068&#039;
[string]$appArch = &#039;x86&#039;
[string]$appLang = &#039;EN&#039;
[string]$appRevision = &#039;01&#039;
[string]$appScriptVersion = &#039;1.0.0&#039;
[string]$appScriptDate = &#039;04/06/2016&#039;
[string]$appScriptAuthor = &#039;IT&#039;
##*===============================================
## Variables: Install Titles (Only set here to override defaults set by the toolkit)
[string]$installName = &#039;&#039;
[string]$installTitle = &#039;&#039;

##* Do not modify section below
#region DoNotModify

## Variables: Exit Code
[int32]$mainExitCode = 0

## Variables: Script
[string]$deployAppScriptFriendlyName = &#039;Deploy Application&#039;
[version]$deployAppScriptVersion = [version]&#039;3.6.8&#039;
[string]$deployAppScriptDate = &#039;02/06/2016&#039;
[hashtable]$deployAppScriptParameters = $psBoundParameters

## Variables: Environment
If (Test-Path -LiteralPath &#039;variable:HostInvocation&#039;) { $InvocationInfo = $HostInvocation } Else { $InvocationInfo = $MyInvocation }
[string]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent

## Dot source the required App Deploy Toolkit Functions
Try {
	[string]$moduleAppDeployToolkitMain = &quot;$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1&quot;
	If (-not (Test-Path -LiteralPath $moduleAppDeployToolkitMain -PathType &#039;Leaf&#039;)) { Throw &quot;Module does not exist at the specified location [$moduleAppDeployToolkitMain].&quot; }
	If ($DisableLogging) { . $moduleAppDeployToolkitMain -DisableLogging } Else { . $moduleAppDeployToolkitMain }
}
Catch {
	If ($mainExitCode -eq 0){ [int32]$mainExitCode = 60008 }
	Write-Error -Message &quot;Module [$moduleAppDeployToolkitMain] failed to load: <code>n$($_.Exception.Message)</code>n `n$($_.InvocationInfo.PositionMessage)&quot; -ErrorAction &#039;Continue&#039;
	## Exit the script, returning the exit code to SCCM
	If (Test-Path -LiteralPath &#039;variable:HostInvocation&#039;) { $script:ExitCode = $mainExitCode; Exit } Else { Exit $mainExitCode }
}

#endregion
##* Do not modify section above
##*===============================================
##* END VARIABLE DECLARATION
##*===============================================
	
If ($deploymentType -ine &#039;Uninstall&#039;) {
	##*===============================================
	##* PRE-INSTALLATION
	##*===============================================
	[string]$installPhase = &#039;Pre-Installation&#039;
	
	## Show Welcome Message, close Internet Explorer if required, allow up to 3 deferrals, verify there is enough disk space to complete the install, and persist the prompt
	Show-InstallationWelcome -CloseApps &#039;WINWORD,EXCEL,OUTLOOK,POWERPNT,ONENOTE,MSPUB,NitroPDF&#039; -BlockExecution -AllowDefer -CheckDiskSpace -PersistPrompt -CloseAppsCountdown 60
	
	## Show Progress Message (with the default message)
	Show-InstallationProgress -StatusMessage “Office 365 Installation in Progress…The Installation may take up to 45 minutes to complete.”
	
	## &lt;Perform Pre-Installation tasks here&gt;
	
	
	##*===============================================
	##* INSTALLATION 
	##*===============================================
	[string]$installPhase = &#039;Installation&#039;

    ## Handle Zero-Config MSI Installations
	If ($useDefaultMsi) {
		[hashtable]$ExecuteDefaultMSISplat =  @{ Action = &#039;Install&#039;; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add(&#039;Transform&#039;, $defaultMstFile) }
		Execute-MSI @ExecuteDefaultMSISplat; If ($defaultMspFiles) { $defaultMspFiles | ForEach-Object { Execute-MSI -Action &#039;Patch&#039; -Path $_ } }
	}
	
	## &lt;Perform Installation tasks here&gt;
    ##Show-InstallationProgress -StatusMessage &quot;Upgrading to the NEW Office 2016. Please wait while installation completes...&quot; 
    Execute-Process -Path “.\Setup.exe” -Parameters “/configure /configuration.xml”
	
	##*===============================================
	##* POST-INSTALLATION
	##*===============================================
	[string]$installPhase = &#039;Post-Installation&#039;
	
	## &lt;Perform Post-Installation tasks here&gt;
	
	## Display a message at the end of the install
	If (-not $useDefaultMsi) { Show-InstallationPrompt -Message &#039;Your Office Upgrade has been Completed. Should you have any questions, please call the Help Desk at (954)627-9353&#039; -ButtonRightText &#039;OK&#039; -Icon Information -NoWait }
}
ElseIf ($deploymentType -ieq &#039;Uninstall&#039;)
{
	##*===============================================
	##* PRE-UNINSTALLATION
	##*===============================================
	[string]$installPhase = &#039;Pre-Uninstallation&#039;
	
	## Show Welcome Message, close Internet Explorer with a 60 second countdown before automatically closing
	Show-InstallationWelcome -CloseApps &#039;iexplore&#039; -CloseAppsCountdown 60
	
	## Show Progress Message (with the default message)
	Show-InstallationProgress
	
	## &lt;Perform Pre-Uninstallation tasks here&gt;
	
	
	##*===============================================
	##* UNINSTALLATION
	##*===============================================
	[string]$installPhase = &#039;Uninstallation&#039;
	
	## Handle Zero-Config MSI Uninstallations
	If ($useDefaultMsi) {
		[hashtable]$ExecuteDefaultMSISplat =  @{ Action = &#039;Uninstall&#039;; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add(&#039;Transform&#039;, $defaultMstFile) }
		Execute-MSI @ExecuteDefaultMSISplat
	}
	
	# &lt;Perform Uninstallation tasks here&gt;
	
	
	##*===============================================
	##* POST-UNINSTALLATION
	##*===============================================
	[string]$installPhase = &#039;Post-Uninstallation&#039;
	
	## &lt;Perform Post-Uninstallation tasks here&gt;
	
	
}

##*===============================================
##* END SCRIPT BODY
##*===============================================

## Call the Exit-Script function to perform final cleanup operations
Exit-Script -ExitCode $mainExitCode

}
Catch {
[int32]$mainExitCode = 60001
[string]$mainErrorMessage = "$(Resolve-Error)"
Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
Exit-Script -ExitCode $mainExitCode
}

Hi Jason,

I know this forum is 4 weeks old but I stumbled upon it in my search to finding a way to use the deployment toolkit to install Office 365 2016. I saw your setup but I can’t seem to get mine to work. I keep receiving an error balloon stating “Installation Failed” from the taskbar. Not sure what I am missing but here is the script I developed. Can you or anyone else see where am I going wrong? I already placed all of the files for office install (ie. setup.exe and the .xml) within the same folder as the “Deploy-Application.ps1″.

<pre class=”brush: powershell; gutter: true; first-line: 1; highlight: []; html-script: false”><#
.SYNOPSIS
This script performs the installation or uninstallation of an application(s).
.DESCRIPTION
The script is provided as a template to perform an install or uninstall of an application(s).
The script either performs an “Install” deployment type or an “Uninstall” deployment type.
The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.
The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
.PARAMETER DeploymentType
The type of deployment to perform. Default is: Install.
.PARAMETER DeployMode
Specifies whether the installation should be run in Interactive, Silent, or NonInteractive mode. Default is: Interactive. Options: Interactive = Shows dialogs, Silent = No dialogs, NonInteractive = Very silent, i.e. no blocking apps. NonInteractive mode is automatically set if it is detected that the process is not user interactive.
.PARAMETER AllowRebootPassThru
Allows the 3010 return code (requires restart) to be passed back to the parent process (e.g. SCCM) if detected from an installation. If 3010 is passed back to SCCM, a reboot prompt will be triggered.
.PARAMETER TerminalServerMode
Changes to “user install mode” and back to “user execute mode” for installing/uninstalling applications for Remote Destkop Session Hosts/Citrix servers.
.PARAMETER DisableLogging
Disables logging to file for the script. Default is: $false.
.EXAMPLE
powershell.exe -Command “& { & ‘.\Deploy-Application.ps1’ -DeployMode ‘Silent’; Exit $LastExitCode }”
.EXAMPLE
powershell.exe -Command “& { & ‘.\Deploy-Application.ps1’ -AllowRebootPassThru; Exit $LastExitCode }”
.EXAMPLE
powershell.exe -Command “& { & ‘.\Deploy-Application.ps1’ -DeploymentType ‘Uninstall’; Exit $LastExitCode }”
.EXAMPLE
Deploy-Application.exe -DeploymentType “Install” -DeployMode “Silent”
.NOTES
Toolkit Exit Code Ranges:
60000 – 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
69000 – 69999: Recommended for user customized exit codes in Deploy-Application.ps1
70000 – 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
.LINK
http://psappdeploytoolkit.com
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory=$false)]
[ValidateSet(‘Install’,‘Uninstall’)]
[string]$DeploymentType = ‘Install’,
[Parameter(Mandatory=$false)]
[ValidateSet(‘Interactive’,‘Silent’,‘NonInteractive’)]
[string]$DeployMode = ‘Interactive’,
[Parameter(Mandatory=$false)]
[switch]$AllowRebootPassThru = $false,
[Parameter(Mandatory=$false)]
[switch]$TerminalServerMode = $false,
[Parameter(Mandatory=$false)]
[switch]$DisableLogging = $false
)

Try {

Set the script execution policy for this process

Try { Set-ExecutionPolicy -ExecutionPolicy ‘ByPass’ -Scope ‘Process’ -Force -ErrorAction ‘Stop’ } Catch {}

##===============================================
##
VARIABLE DECLARATION
##*===============================================

Variables: Application

[string]$appVendor = ‘Microsoft’
[string]$appName = ‘Office 2016’
[string]$appVersion = ‘16.0.6001.1068’
[string]$appArch = ‘x86’
[string]$appLang = ‘EN’
[string]$appRevision = ‘01’
[string]$appScriptVersion = ‘1.0.0’
[string]$appScriptDate = ‘04/06/2016’
[string]$appScriptAuthor = ‘IT’
##*===============================================

Variables: Install Titles (Only set here to override defaults set by the toolkit)

[string]$installName = ‘’
[string]$installTitle = ‘’

##* Do not modify section below
#region DoNotModify

Variables: Exit Code

[int32]$mainExitCode = 0

Variables: Script

[string]$deployAppScriptFriendlyName = ‘Deploy Application’
[version]$deployAppScriptVersion = [version]‘3.6.8’
[string]$deployAppScriptDate = ‘02/06/2016’
[hashtable]$deployAppScriptParameters = $psBoundParameters

Variables: Environment

If (Test-Path -LiteralPath ‘variable:HostInvocation’) { $InvocationInfo = $HostInvocation } Else { $InvocationInfo = $MyInvocation }
[string]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent

Dot source the required App Deploy Toolkit Functions

Try {
[string]$moduleAppDeployToolkitMain = “$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1”
If (-not (Test-Path -LiteralPath $moduleAppDeployToolkitMain -PathType ‘Leaf’)) { Throw “Module does not exist at the specified location [$moduleAppDeployToolkitMain].” }
If ($DisableLogging) { . $moduleAppDeployToolkitMain -DisableLogging } Else { . $moduleAppDeployToolkitMain }
}
Catch {
If ($mainExitCode -eq 0){ [int32]$mainExitCode = 60008 }
Write-Error -Message “Module [$moduleAppDeployToolkitMain] failed to load: n$($.Exception.Message)n `n$($.InvocationInfo.PositionMessage)” -ErrorAction ‘Continue’

Exit the script, returning the exit code to SCCM

If (Test-Path -LiteralPath ‘variable:HostInvocation’) { $script:ExitCode = $mainExitCode; Exit } Else { Exit $mainExitCode }
}

#endregion
##* Do not modify section above
##===============================================
##
END VARIABLE DECLARATION
##*===============================================

If ($deploymentType -ine ‘Uninstall’) {
##===============================================
##
PRE-INSTALLATION
##*===============================================
[string]$installPhase = ‘Pre-Installation’

Show Welcome Message, close Internet Explorer if required, allow up to 3 deferrals, verify there is enough disk space to complete the install, and persist the prompt

Show-InstallationWelcome -CloseApps ‘WINWORD,EXCEL,OUTLOOK,POWERPNT,ONENOTE,MSPUB,NitroPDF’ -BlockExecution -AllowDefer -CheckDiskSpace -PersistPrompt -CloseAppsCountdown 60

Show Progress Message (with the default message)

Show-InstallationProgress -StatusMessage “Office 365 Installation in Progress…The Installation may take up to 45 minutes to complete.”

<Perform Pre-Installation tasks here>

##===============================================
##
INSTALLATION
##*===============================================
[string]$installPhase = ‘Installation’

Handle Zero-Config MSI Installations

If ($useDefaultMsi) {
[hashtable]$ExecuteDefaultMSISplat = @{ Action = ‘Install’; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add(‘Transform’, $defaultMstFile) }
Execute-MSI @ExecuteDefaultMSISplat; If ($defaultMspFiles) { $defaultMspFiles | ForEach-Object { Execute-MSI -Action ‘Patch’ -Path $_ } }
}

<Perform Installation tasks here>

##Show-InstallationProgress -StatusMessage “Upgrading to the NEW Office 2016. Please wait while installation completes…”
Execute-Process -Path “.\Setup.exe” -Parameters “/configure /configuration.xml”

##===============================================
##
POST-INSTALLATION
##*===============================================
[string]$installPhase = ‘Post-Installation’

<Perform Post-Installation tasks here>

Display a message at the end of the install

If (-not $useDefaultMsi) { Show-InstallationPrompt -Message 'Your Office Upgrade has been Completed. Should you have any questions, please call the Help Desk -ButtonRightText ‘OK’ -Icon Information -NoWait }
}
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 Progress Message (with the default message)

Show-InstallationProgress

<Perform Pre-Uninstallation tasks here>

##===============================================
##
UNINSTALLATION
##*===============================================
[string]$installPhase = ‘Uninstallation’

Handle Zero-Config MSI Uninstallations

If ($useDefaultMsi) {
[hashtable]$ExecuteDefaultMSISplat = @{ Action = ‘Uninstall’; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add(‘Transform’, $defaultMstFile) }
Execute-MSI @ExecuteDefaultMSISplat
}

<Perform Uninstallation tasks here>

##===============================================
##
POST-UNINSTALLATION
##*===============================================
[string]$installPhase = ‘Post-Uninstallation’

<Perform Post-Uninstallation tasks here>

}

##===============================================
##
END SCRIPT BODY
##*===============================================

Call the Exit-Script function to perform final cleanup operations

Exit-Script -ExitCode $mainExitCode
}
Catch {
[int32]$mainExitCode = 60001
[string]$mainErrorMessage = “$(Resolve-Error)”
Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
Show-DialogBox -Text $mainErrorMessage -Icon ‘Stop’
Exit-Script -ExitCode $mainExitCode
}

Great script! I’ve been going nuts with trying to do it the microsoft way. Keep getting stupid errors.
Anyway, how are you triggering the “ifshared” switch?

Also, have you come up with any switches to add to this script to add additional apps such as Visio and Project? We are installing the base software (minus groove/onedrive and access) but would like to utilize this script to add visio or project with a switch.

Thoughts?

This is my script that I use to upgrade any previous Office version to Office 365 ProPlus 2016 CLick to Run.

We have PC’s with Office 2007, 2010 and 2013.
As we are planning to upgrade all of them to the latest version I’ve created this script that will do just that.
I used a couple of snippets from the example script as it contained some useful stuff.
I’ve also made interactive so our users receive an informational message of what’s going to happen.

The script first scans for installed Office version and removes them before installing new version.
I use these Offscrub files:

OffScrub03.vbs
OffScrub07.vbs
OffScrub10.vbs
OffScrub_O15msi.vbs
OffScrubc2r.vbs

For your reference, here is the folder structure of the PsAppDeploykit working directory:

I’ve deployed it via SCCM 2012:
Installation program: Deploy-Application.exe -DeploymentType Install -DeployMode Interactive

For the “interactive” part don’t forget to change the “User Experience” to:

As the formatting will probably be screwed when I post the script here, I’m sharing the complete working directory with you (except the Office source files).
-> All Offscrub files as well as my XML files that I’ve used.
https://drive.google.com/open?id=0B1RmM7netsG3ZlRMUVdfd2d5UWs

If you don’t want to download the source files, I’ve posted the script also on the Technet forums:
https://social.technet.microsoft.com/Forums/office/en-US/aa81d5a8-779a-482c-9c02-e187ab5d635f/office-2010-x64-x86-removal?forum=officesetupdeploy#32c80aac-09e7-42bd-b373-712f1aa47807

hello Aldin,

I’m running into some detection issues with your PADT when install Office 365 2016. I’ve essentially copied your .ps1 and deployed it to a few test machines in my environment. Most of my machines have Office 2013 (VL) with Skype 2015 installed. The office scrub works very well and rips out all Office that is initially on the machine.

The part that gets stuck is shown in the logs files for PADT:

[Pre-Installation] :: Bypassing Installation Prompt [Mode: NonInteractive]… This will install Microsoft Office 365 ProPlus 2016 for you. Please note that the installation can take up to 45 minutes.
All previous Office versions will be uninstalled first.
Save all your work and click OK to continue. Show-InstallationPrompt 4/17/2017 2:15:08 PM 1276 (0x04FC)

[Pre-Installation] :: Evaluate disk space requirements. Show-InstallationWelcome 4/17/2017 2:15:13 PM 1276 (0x04FC)

[Pre-Installation] :: Retrieve free disk space for drive [C:]. Get-FreeDiskSpace 4/17/2017 2:15:13 PM 1276 (0x04FC)

[Pre-Installation] :: Free disk space for drive [C:]: [22014 MB]. Get-FreeDiskSpace 4/17/2017 2:15:13 PM 1276 (0x04FC)

[Pre-Installation] :: Successfully passed minimum disk space requirement check. Show-InstallationWelcome 4/17/2017 2:15:13 PM 1276 (0x04FC)

[Pre-Installation] :: Check for running application(s) [ose,osppsvc,sppsvc,msoia,excel,groove,onenote,infopath,onenote,outlook,mspub,powerpnt,winword,winproj,visio,iexplore]… Get-RunningProcesses 4/17/2017 2:15:13 PM 1276 (0x04FC)

[Pre-Installation] :: Application(s) are not running. Get-RunningProcesses 4/17/2017 2:15:13 PM 1276 (0x04FC)

[Pre-Installation] :: Finished checking running application(s). Get-RunningProcesses 4/17/2017 2:15:13 PM 1276 (0x04FC)

[Pre-Installation] :: Microsoft Office 2010 was detected. Will be uninstalled. Deploy Application 4/17/2017 2:15:13 PM 1276 (0x04FC)

[Pre-Installation] :: [cscript.exe] successfully resolved to fully qualified path [C:\WINDOWS\system32\cscript.exe]. Execute-Process 4/17/2017 2:15:13 PM 1276 (0x04FC)

[Pre-Installation] :: Working Directory is [C:\WINDOWS\system32]. Execute-Process 4/17/2017 2:15:13 PM 1276 (0x04FC)

[Pre-Installation] :: Executing [C:\WINDOWS\system32\cscript.exe “C:\WINDOWS\ccmcache\4z\SupportFiles\OffScrub10.vbs” ProPlus,Pro,Standard,SINGLEIMAGE /S /Q /NoCancel /Bypass 1]… Execute-Process 4/17/2017 2:15:13 PM 1276 (0x04FC)

[Pre-Installation] :: Execution completed successfully with exit code [0]. Execute-Process 4/17/2017 2:17:42 PM 1276 (0x04FC)

[Pre-Installation] :: Microsoft Office 2013 was detected. Will be uninstalled. Deploy Application 4/17/2017 2:17:42 PM 1276 (0x04FC)

[Pre-Installation] :: [cscript.exe] successfully resolved to fully qualified path [C:\WINDOWS\system32\cscript.exe]. Execute-Process 4/17/2017 2:17:42 PM 1276 (0x04FC)

[Pre-Installation] :: Working Directory is [C:\WINDOWS\system32]. Execute-Process 4/17/2017 2:17:42 PM 1276 (0x04FC)

[Pre-Installation] :: Executing [C:\WINDOWS\system32\cscript.exe “C:\WINDOWS\ccmcache\4z\SupportFiles\OffScrub_O15msi.vbs” ProPlus,Pro,Standard,SINGLEIMAGE /S /Q /NoCancel /Bypass 1]… Execute-Process 4/17/2017 2:17:42 PM 1276 (0x04FC)

[Pre-Installation] :: Execution completed successfully with exit code [0]. Execute-Process 4/17/2017 2:21:39 PM 1276 (0x04FC)

[Installation] :: [C:\WINDOWS\ccmcache\4z\Files\Setup.exe] is a valid fully qualified path, continue. Execute-Process 4/17/2017 2:21:39 PM 1276 (0x04FC)

[Installation] :: Working Directory is [C:\WINDOWS\ccmcache\4z\Files]. Execute-Process 4/17/2017 2:21:39 PM 1276 (0x04FC)

[Installation] :: Executing [C:\WINDOWS\ccmcache\4z\Files\Setup.exe /configure ProPlus-InstallConfig.xml]… Execute-Process 4/17/2017 2:21:39 PM 1276 (0x04FC)

It gets stuck at this spot where its trying to install Office 365 2016 using the setup.exe with the /configure .xml file applied.

On the computer that’s getting Office 365 installed, the basic UI shows up and it eventually shows that it completes the install. However the log file above still reports it as Executing. This makes the SCCM software center hang on “Installing” and the end user is forced to restart their machine in order to move on to installing other Office 365 apps like Visio Pro or Project Pro.

Have you ran into this issue before? Is there some type of powershell timer that I can implement into the script to essentially “jolt” it to move on?

Thanks
Dean

Hi Aldin,

great Package. Could you please give me a hint, how to deal with multiple configuration.xmls for different languages.
I have a package containing all language packs that i need and created for each language a seperate configuration XML (e. g. en-us.xml, pt-pt.xml, de-de.xml). Now I have the Problem to call the right language based on the current OS language or formerly installed Office Language. Any ideas.
Thank in advance.

According to the documentation, there is a toolkit variable called $currentLanguage that contains the two-letter language name of the target system (e.g., EN, FR, DE, etc). Could maybe do something like:

Execute-Process -Path “$dirFiles\Setup.exe” -Parameters “/configure $currentLanguage.xml”

Hi Shaun,
thanks for that hint. I also figured out that variable today morning, but had a different way. I have used the if statement and called each config.xml in a separate step. Your proposal sounds better. Will try it as soon as possible.

Many thanks and best regards.

Hi,

I’m sorry I just saw this message.
Can you share your XML file with me?
Also what version of ODT (Office Deployment Tool) are you using?

I honestly didn’t have any similar issues.
I’ve upgraded office on 800+ devices successfully without any major issues.

Thanks for posting this. Did you ever include the off16scrub to your script? I see its included in the files but not referenced in the script.

Hi Anwer,

I did not include it because we didn’t have Office 2016 MSI in our environment at the time.
I did include in the file so others can just edit the script a little to include it.
It shouldn’t be that hard.

First off, I would like to thank you Aldin for providing this script, so far it has been working really well. The only issue I am currently running into is that sometimes after the scrub runs(and it is usually OffScrubC2R) I will get “[Pre-Installation] :: Execution complete and the exit code [42] is being ignored.” and then it will go on to start installing office but the Office install hangs for the entire 2 hour window I have allotted the install via SCCM. After the 2 hour mark it is canceled and the installation fails. If I reboot the machine and run it again, it seems to work. I do have machines that get the same error, with OffScrubC2R, and it has no issues installing office. Any advice would be much appreciated, thank you.

Just FYI - it’s easier to just use the following config.xml to remove all previous versions of Office;

        <Configuration>
      <Add OfficeClientEdition="64" Channel="Monthly" >
          <Product ID="O365ProPlusRetail">
             <Language ID="en-us" />
          </Product>
      </Add>
  <RemoveMSI All="True" />
    </Configuration>

what if you have a mix of win7 32bit and 64bit, win10 64bit…
what if in that mix there is office 2010 32bit and 64bit, 2013, 2016 C2R…
what if you want to keep visio and project versions…

you need to uninstall first.

but im also using ivanti to deploy and the client is located in the program files folder…

similar to /u/aldin i put all the microsoft uninstall tools in the “SupportFiles” folder.
You can get the files from:

Its important you get all the files and that they run locally from the machine when executed otherwise it wont work.

different to /u/aldin i use the 'Remove-PreviousOfficeInstalls.ps1
i define 3 strings:

  1. define the program files folder. this is needed because it is different for x86 and x64 systems
  2. define the location of the microsoft office removal script
  3. define the arguments for the microsoft office removal script
    this saves many 10s of lines of code:

Display Pre-Install cleanup status

Show-InstallationProgress -StatusMessage “Performing Pre-Install cleanup. Removing Prior Office Versions… This may take some time. Please wait…”

[string]programsdir = ({env:ProgramFiles(x86)}, ${env:ProgramFiles} -ne $null)[0]

[string]$removeoffice = “$programsdir\LANDesk\LDClient\sdmcache\psappdeploytoolkit\SupportFiles\Remove-PreviousOfficeInstalls.ps1”

[string]$removeofficeargs = “-ProductsToRemove MainOfficeProduct -RemoveClickToRunVersions 1 -Remove2016Installs 1 -Force 1 -KeepUserSettings 1 -KeepLync 0 -NoReboot 1 -Quiet 1”

Invoke-Expression “& '$removeoffice’ $removeofficeargs”

Then the install is straight forward as ‘$programsdir’ can be reused

Display Install status

Show-InstallationProgress -StatusMessage ‘Microsoft Office 365 C2R 16.0.10730.20264 is now installing. This may take some time. Please wait…’

[string]$installO365FORCE = “$programsdir\LANDesk\LDClient\sdmcache\psappdeploytoolkit\Files”

Execute-Process -Path “$installO365FORCE\setup.exe” -Parameters "/configure "$installO365FORCE\ConfigurationFULLdisplayFORCE.xml“” -WindowStyle Hidden

i have also posted the answer to technet as it captures the backspaces in the ‘Invoke-Expression’ and ‘Execute-Process’ commands that are crucial to the script executing

https://social.technet.microsoft.com/Forums/windows/en-US/aa81d5a8-779a-482c-9c02-e187ab5d635f/office-2010-x64-amp-x86-removal?forum=officesetupdeploy

Actually, all of tat is not required anymore.
While I’m sure it works, you can configure you XML file for the Office Dpeloyment Tool to uninstall all previous MSI versions of Office and even specify which MSI Office apps to exclude, like Visio and Project etc…

You can use PSADT to first detect Office Bit (32 or 64) version and to call the correct XML.
Or you can create two deployment types in SCCM and use a Global Condition to detect Office bit version.
I use a Global Conditionf for instance…

Anyway…
Take this XML as an example.

It will

  • Uninstall Skype for Business Basic, if installed
  • Uninstall all MSI versions of any Office product installed
  • MSI Products defined in between IgnoreProduct tags will not be uninstalled
  • Exclude Groove (OneDrive for Business old client)
  • Exclude OneNote (OneNote is not updated anymore and the Windows Store app should be used)
  • Configure some default settings
    -> Roaming of QuickAccess toolbar settings (will be same on each device you login to Office)
    -> Set XML file types for Office so the prompt is not shown first time Word etc opens
  • and eventually: install Office 365 ProPlus 64 Bit
    -> Install en-UN language pack
    -> Install only Proofing Tools for selected languages (no complete language packs)
  • Enable Updates

Perhaps it’s too much, but I just wanted to show that most of the things you wish to achieve can now be done with the XML only.

<Configuration>
  <Remove>
    <Product ID="SkypeforBusinessEntryRetail" ALL="TRUE" />
  </Remove>
  <Add OfficeClientEdition="64" Channel="Broad" Version="-1" AllowCdnFallback="TRUE" ForceUpgrade="TRUE">
    <Product ID="O365ProPlusRetail">
      <Language ID="en-us" />
      <ExcludeApp ID="Groove" />
	  <ExcludeApp ID="OneNote" />
    </Product>
	<Product ID="ProofingTools">
	  <Language ID="nl-nl" />
      <Language ID="da-dk" />
      <Language ID="fr-fr" />
      <Language ID="de-de" />
      <Language ID="it-it" />
      <Language ID="pt-br" />
      <Language ID="ru-ru" />
      <Language ID="es-es" />
    </Product> 	
  </Add>
  <RemoveMSI>
    <IgnoreProduct ID="InfoPath" />
    <IgnoreProduct ID="InfoPathR" />
    <IgnoreProduct ID="PrjPro" />
    <IgnoreProduct ID="PrjStd" />
    <IgnoreProduct ID="VisPro" />
    <IgnoreProduct ID="VisStd" />
	<IgnoreProduct ID="VISIO" />
  </RemoveMSI>
  <AppSettings>
    <Setup Name="Company" Value="YOUR COMPANY NAME HERE" />
    <User Key="software\microsoft\office\16.0\common\toolbars" Name="customuiroaming" Value="1" Type="REG_DWORD" App="office16" Id="L_AllowRoamingQuickAccessToolBarRibbonCustomizations" />
	<User Key="software\microsoft\office\16.0\excel\options" Name="defaultformat" Value="51" Type="REG_DWORD" App="excel16" Id="L_SaveExcelfilesas" />
    <User Key="software\microsoft\office\16.0\powerpoint\options" Name="defaultformat" Value="27" Type="REG_DWORD" App="ppt16" Id="L_SavePowerPointfilesas" />
    <User Key="software\microsoft\office\16.0\word\options" Name="defaultformat" Value="" Type="REG_SZ" App="word16" Id="L_SaveWordfilesas" />
  </AppSettings>
  <Display Level="None" AcceptEULA="TRUE"/>
  <Logging Level="Standard" Path="C:\LogFiles\Office365ProPlus_Install"/>
  <Property Name="SharedComputerLicensing" Value="0" />
  <Property Name="FORCEAPPSHUTDOWN" Value="TRUE" />
  <Property Name="PinIconsToTaskbar" Value="FALSE"/>
  <Property Name="SCLCacheOverride" Value="0" />
  <Updates Enabled="TRUE" Channel="Broad"/>
</Configuration>
1 Like

I was wondering about the statement:

You can use PSADT to first detect Office Bit (32 or 64) version and to call the correct XML.

How does PSADT detect if it is office 32 or 64 and what is the best method to utilize the property?

I think I have discovered the answer. The function Get-InstalledApplication has a property of Is64BitApplication.