Help me about managing Custom Exit Codes

Hi All,

As I’m not able to find an already created funcion in the main regarding Custom Exit Codes, I want to implement a Basic ExitCode check after running an installation.

I’ve tried it with SUCCESS but I tested setting manually exit code 15 as OK, the Appdeploy runs correctly, the registry keys are well set, the message Shows as SUCCESS but the Windows Balloon shows the installation result as ERROR with the RED X near the Clock.

Here my current code:

<Perform Installation tasks here>

$InstallPowerBI = Execute-MSI -Action ‘Install’ -Path ‘PBIDesktop_x64.msi’ -AddParameters ‘ACCEPT_EULA=1 INSTALLDESKTOPSHORTCUT=0’ -PassThru -ContinueOnError $true

$mainExitCode = $InstallPowerBI.ExitCode

[string]$installPhase = ‘Post-Installation’

## &lt;Perform Post-Installation tasks here&gt;

Invoke-SCCMTask 'HardwareInventory'
Invoke-SCCMTask 'SoftwareInventory'

if (($mainExitCode -ne "3010") -and ($mainExitCode -ne "0") -and ($mainExitCode -ne "15"))
  Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\&lt;CompanyName&gt;\$appVendor\$appName<code>_$appVersion</code>_$appLang<code>_$appRevision</code>_$appOS`_$appArch" -Name 'Result' -Value 'ERROR' -Type String
  If (-not $useDefaultMsi) { Show-InstallationPrompt -Message "The installation of the application $installTitle FAILED." -ButtonRightText 'OK' -Icon Information -NoWait }
  Exit-Script -ExitCode $mainExitCode
  Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\&lt;CompanyName&gt;\$appVendor\$appName<code>_$appVersion</code>_$appLang<code>_$appRevision</code>_$appOS`_$appArch" -Name 'Result' -Value 'Success' -Type String
  ## Display a message at the end of the install
  If (-not $useDefaultMsi) { Show-InstallationPrompt -Message "The installation of the application $installTitle was successful." -ButtonRightText 'OK' -Icon Information -NoWait }

ElseIf ($deploymentType -ieq ‘Uninstall’)

I would like to define a variable at the beggining of the script like:

$AcceptedExitCodes = “0”,“3010”,“1618”

and then compare it in like this:

if (($mainExitCode -ne $AcceptedExitCodes)



or just create a Function called “ExitCodeFunction” in the Extensions and run it at the end, but I think I’m missing something with the Balloon Error. I’ve already checked the Config.xml but nothing.

Can someone help me in this?

Really appreciate it.