I have my silent installation PowerShell script but I have issue that even if some of the arguments are not correct my execution of the powershell script will not fail.
$expression="C:\app\tool.exe /COMPUTER=server1 /INSTALL /SILENT"
try {
Invoke-Expression $expression -ErrorAction Stop
}
catch {
Write-Host "Entered Exception"
}
Unfortunately it's always "green", like execution was successful and no Errors have been thrown.
In the log however I can see that it was "Unintended cancel" of the setup.
******************************************************** Error:
Connect to computer registry failed
Computer 'SERVER1' does not exist
The network path was not found.
Unattended setup >>> 'Cancel'
********************************************************
Exit code = 0x4C7
My script does not enter the catch
clause.
Is it possible that I can somehow force this to fail, so I can catch that error.
I am having big issue that my powershell does not fail, although it should because it got wrong installation argument.
Thank you!!!