Fixed error handling
This commit is contained in:
@@ -71,28 +71,30 @@ param (
|
|||||||
|
|
||||||
$ConfigurationXML = "$($InstallRoot)\$($SKU)\$($Channel)\configuration.xml"
|
$ConfigurationXML = "$($InstallRoot)\$($SKU)\$($Channel)\configuration.xml"
|
||||||
|
|
||||||
try {
|
If (!(Test-Path $ConfigurationXML)) {
|
||||||
Test-Path $ConfigurationXML -ErrorAction STOP
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
throw "Unable to locate a configuration XML file at $($ConfigurationXML)"
|
throw "Unable to locate a configuration XML file at $($ConfigurationXML)"
|
||||||
}
|
}
|
||||||
|
|
||||||
$setuppath = "$($InstallRoot)\$($SKU)\$($Channel)\Setup.exe"
|
$setuppath = "$($InstallRoot)\$($SKU)\$($Channel)\Setup.exe"
|
||||||
try {
|
|
||||||
|
|
||||||
}
|
if (!(Test-Path $setuppath)) {
|
||||||
catch {
|
|
||||||
throw "Unable to locate a Setup.exe file at $($setuppath)"
|
throw "Unable to locate a Setup.exe file at $($setuppath)"
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Attempting to install Office 365 $($SKU) $($Channel)"
|
Write-Host "Attempting to install Office 365 $($SKU) $($Channel)"
|
||||||
$process = Start-Process -FilePath "$($InstallRoot)\$($SKU)\$($Channel)\Setup.exe" -ArgumentList "/Configure $($InstallRoot)\$($SKU)\$($Channel)\configuration.xml" -Wait -PassThru
|
|
||||||
if ($process.ExitCode -eq 0)
|
try {
|
||||||
{
|
$process = Start-Process -FilePath "$($InstallRoot)\$($SKU)\$($Channel)\Setup.exe" -ArgumentList "/Configure $($InstallRoot)\$($SKU)\$($Channel)\configuration.xml" -Wait -PassThru -ErrorAction STOP
|
||||||
Write-Host -ForegroundColor Green "Office setup started without error."
|
|
||||||
|
if ($process.ExitCode -eq 0)
|
||||||
|
{
|
||||||
|
Write-Host -ForegroundColor Green "Office setup started without error."
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Write-Warning "Installer exit code $($process.ExitCode)."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch {
|
||||||
{
|
Write-Warning $_.Exception.Message
|
||||||
Write-Warning "Installer exit code $($process.ExitCode)."
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user