Open jameschappy opened 6 years ago
Just wanted to add, I was experiencing the same issue with Office 2016 MSI removals and this change resolved.
Where you insert this if (!$office16removed) statement. I'm powershell newbie. I have checked this code exists in the script.`"16.*"{
if($Remove2016Installs){
if($product.ClickToRun -eq $true){
$c2r2016Installed = $true
}
if(!$c2r2016Installed){
$ActionFile = "$scriptPath\$16MSIVBS"
} else {
if($RemoveClickToRunVersions){
$ActionFile = "$scriptPath\$c2rVBS"
} else {
WriteToLogFile -LNumber $(LINENUM) -FName $currentFileName -ActionError "Office 2016 cannot be removed if 2016 Click-To-Run is installed. Use the -RemoveClickToRunVersions parameter to remove Click-To-Run installs." -LogFilePath $LogFilePath
throw "Office 2016 cannot be removed if 2016 Click-To-Run is installed. Use the -RemoveClickToRunVersions parameter to remove Click-To-Run installs."
}
}
$cmdLine = """$ActionFile"" CLIENTALL $argList"
$cmd = "cmd /c cscript //Nologo $cmdLine"
Invoke-Expression $cmd
$office16Removed = $true`
Where you insert this if (!$office16removed) statement. I'm powershell newbie. I have checked this code exists in the script.`"16.*"{ if($Remove2016Installs){ if($product.ClickToRun -eq $true){ $c2r2016Installed = $true } if(!$c2r2016Installed){ $ActionFile = "$scriptPath$16MSIVBS" } else { if($RemoveClickToRunVersions){ $ActionFile = "$scriptPath$c2rVBS" } else { WriteToLogFile -LNumber $(LINENUM) -FName $currentFileName -ActionError "Office 2016 cannot be removed if 2016 Click-To-Run is installed. Use the -RemoveClickToRunVersions parameter to remove Click-To-Run installs." -LogFilePath $LogFilePath throw "Office 2016 cannot be removed if 2016 Click-To-Run is installed. Use the -RemoveClickToRunVersions parameter to remove Click-To-Run installs." } }
$cmdLine = """$ActionFile"" CLIENTALL $argList" $cmd = "cmd /c cscript //Nologo $cmdLine" Invoke-Expression $cmd $office16Removed = $true`
Hello,
We are using remove-previousofficeinstalls. We are replacing a number of office versions with 2016 CTR (including 2016 MSI).
We noticed that the powershell script invokes OffScrub_016msi numerous times. Even though it completes successfully the first time.
The following snippit of code sets '$office16Removed = $true' once OffScrub_016msi has been invoked. However, the code does not check for the existence of the variable in the next loop and runs OffScrub_016msi again (25 times in our example).
We have wrapped everything in another 'if (!$office16removed)' condition and it seems to have resolved the issue. Cheers
"16.*"{ if($Remove2016Installs){ if($product.ClickToRun -eq $true){ $c2r2016Installed = $true }