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>"$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>"$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>"$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>"$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>"$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>"$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>"$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>"$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 }
## <Perform Installation tasks here>
## 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'
## <Perform Post-Installation tasks here>
## 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
## <Perform Pre-Uninstallation tasks here>
##*===============================================
##* UNINSTALLATION
##*===============================================
[string]$installPhase = 'Uninstallation'
## Handle Zero-Config MSI Uninstallations
If ($useDefaultMsi) { Execute-MSI -Action 'Uninstall' -Path $defaultMsiFile }
# <Perform Uninstallation tasks here>
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'
## <Perform Post-Uninstallation tasks here>
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
}