alter_ego_dev2
Posts: 24
Joined: Wed May 10, 2023 4:09 pm

How to setup PowerShell custom action to provide details in case of action fail?

Hey,
Our app has several custom action with a PowerShell script. Advanced installer analytics shows exceptions for these custom actions.
The Exception/Overview page has custom action names. The Exception/Details shows custom action names in description column, but the Details column is empty. At the same time user provided installer logs have custom action error description.
Since we would like to see exception details how should we update our PowerShell code (or custom action settings) to provide the exception information to Installer Analytics?
Catalin
Posts: 6782
Joined: Wed Jun 13, 2018 7:49 am

Re: How to setup PowerShell custom action to provide details in case of action fail?

Hello,

If possible, could you please give me some more details about this scenario so I can further investigate this?

It would help if you could provide some screenshots of the issue so I can have a better view of the scenario.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
alter_ego_dev2
Posts: 24
Joined: Wed May 10, 2023 4:09 pm

Re: How to setup PowerShell custom action to provide details in case of action fail?

Catalin wrote: Mon Nov 27, 2023 1:12 pm Hello,

If possible, could you please give me some more details about this scenario so I can further investigate this?

It would help if you could provide some screenshots of the issue so I can have a better view of the scenario.

Best regards,
Catalin
There is a "Run Powershell Inline Script" custom action in an app.
The action should get some information, then install a device using microsoft devcon.exe tool (https://learn.microsoft.com/en-us/windo ... est/devcon).
Simplified version of the script:

Code: Select all

...some logic that get information and combines file paths
& $devconPath $params
...some additional logic that would complete device installation using default PowerShell commands

The script doesn't have any try/catch block and do not return any exit values.
Catalin
Posts: 6782
Joined: Wed Jun 13, 2018 7:49 am

Re: How to setup PowerShell custom action to provide details in case of action fail?

Hello,
The script doesn't have any try/catch block and do not return any exit values.
This is something you should add to your script if you need it.

The script either returns success or error, these are the only options for the Windows Installer service that interprets them.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
alter_ego_dev2
Posts: 24
Joined: Wed May 10, 2023 4:09 pm

Re: How to setup PowerShell custom action to provide details in case of action fail?

Catalin wrote: Wed Nov 29, 2023 12:58 pm Hello,
The script doesn't have any try/catch block and do not return any exit values.
This is something you should add to your script if you need it.

The script either returns success or error, these are the only options for the Windows Installer service that interprets them.

Best regards,
Catalin
Let's have an example! For example, I've added a custom "Run PowerShell Inline Script" action with code:

Code: Select all

try {
    # Some code that may cause an error
}
catch {
    # It is not clear how I should pass an error message to see this message in Advanced Installer Analytics exception details 
    # It seems simple Write-Host doesn't work.
    Write-Host "Encountered Error:"$_.Exception.Message
    exit 1
}
Catalin
Posts: 6782
Joined: Wed Jun 13, 2018 7:49 am

Re: How to setup PowerShell custom action to provide details in case of action fail?

Hello,

What I'm thinking here is that in case of failure, you can set a property and then see it in the "Custom Properties" section of your Installer Analytics account.

Have you tried that?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
alter_ego_dev2
Posts: 24
Joined: Wed May 10, 2023 4:09 pm

Re: How to setup PowerShell custom action to provide details in case of action fail?

Catalin wrote: Mon Dec 04, 2023 3:19 pm Hello,

What I'm thinking here is that in case of failure, you can set a property and then see it in the "Custom Properties" section of your Installer Analytics account.

Have you tried that?

Best regards,
Catalin

I'm sorry, probably, I wasn't clear enough.
At the moment Advanced Installer analytics page looks like this. The first item has only Description "PowerShellCustomAction", but Details part is empty.

Image

PowerShellCustomAction has a try catch blocks, ant the catch block executes "exit 1". In this case, is it possible somehow to configure the PowerShellCustomAction to provide additional error details (if an error appears) and show these details in the Exceptions/Details column (which is empty in the current version) ?

Some of the exceptions (like the second item) have details. Does it mean that "Launch File" when it executes a command line can get an error and pass the error to the Analytics exception page?
Catalin
Posts: 6782
Joined: Wed Jun 13, 2018 7:49 am

Re: How to setup PowerShell custom action to provide details in case of action fail?

Hello,

After some further testing, it looks like this might not be possible currently.

It looks like only the Windows Installer errors are logged into the "Exception" page of Analytics.

I will discuss this matter with the devs and hopefully we can improve the behavior in the future.

Thank you for your understanding!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Installer Analytics”