- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Powershell Report Error Back to Installscript not working?
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Powershell Report Error Back to Installscript not working?
Our service packs use InstallScript projects.
We execute the following InstallScript to run sql scripts:
sFileName= PROGRAMFILES64 ^ "AIR\\Installer\\SqlScriptExecute.bat";
sMsg = "Please wait while setup runs the upgrade scripts";
SdShowMsg ( sMsg, TRUE);
LaunchAppAndWait (sFileName, sSQLServer, WAIT | LAAW_OPTION_HIDDEN);
SdShowMsg ( sMsg, FALSE);
if (LAAW_PARAMETERS.nLaunchResult = 0) then
else
MessageBox("A script failed to execute, please go to Program Files\\AIR\\Logs to check the AIR.ApplySqlUpdate.txt file for more details.", WARNING);
endif;
This code works to report errors back with a single layer, as in:
1. the batch file calls a powershell to execute scripts.
We have since added a new layer to it so it can recursively check multiple folders and do the same, so now the method is:
1. batch file executes powershell
2. powershell executes numerous powershells that execute scripts.
By adding the new layer the installscript isn't capturing errors anymore. If we do the process outside of installscript it works fine, so we know the lack of error reporting isn't coming from the batch file, powershell 1 or powershell 2. Do we need to do something else to get it to capture the error code back to installshield or is the dual layer just an issue for installshield?
Below is the Batch file:
powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0\SqlScriptExecute.ps1' -IServerInstance %1 -verbose"
EXIT /B %ERRORLEVEL%
Below is the Powershell that loops:
#Gets the ServerInstance that is getting based from the Bat file Argument to pass to the loop
param(
[parameter(Mandatory = $true)]
[string] $IServerInstance
)
#Gets the list of all of the paths that have the AIR.ApplySqlUpdate.ps1 file.
$FolderList=Get-ChildItem -Path $PSScriptRoot -Filter "AIR.ApplySqlUpdate.ps1" -Recurse | %{$_.Directory}
#Loops through the list of paths and executes the PS1 file.
$FolderList | ForEach-Object {Push-Location $_
try{
Invoke-Expression -Command "& '$_\AIR.ApplySqlUpdate.ps1' -ServerInstance '$IServerInstance' -verbose -LogDirectory '**PROGRAMFILES**AIR\Logs'"
}
catch{
throw
}
Pop-Location
}