Sending Parameters into Powershell script added as script from disk under custom action - Advanced Installer Community
nskris
Posts: 21
Joined: Fri Oct 26, 2018 3:32 pm

Sending Parameters into Powershell script added as script from disk under custom action

Hi,

Iam trying to send parameters to a powershell script added as script from disk option under custom action but iam unable to do so. The help file shows how to send parameters if i use inline powershell script but it does not show how to do send the same if the powershell script is added as script from disk option. I tried using a similar way as below -
File path: F:\MSI\TestScript.ps1-firstPsParam [SourceDir] -secondPsParam [APPDIR]
When i click on the Test Script button, I get an error saying -
Return code: -1
Script output: "[ERR] Could not find source script file!"
From the above error we can say that the parameters are also being taken as file path resulting in the error.
Can you please help me to find a way to send the parameters into the powershell script?

regards,
Krishna
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Sending Parameters into Powershell script added as script from disk under custom action

Hello Krishna and welcome to our forums,

From what I can see, your custom action has the execution time as "When the system is being modified (deferred)" (please correct me if I'm wrong).

Unfortunately, it is not possible to get a Windows Installer Property's value through a script file. A workaround to this would be to use the "Run PowerShell Inline Script" custom action instead of "Run PowerShell script file" and make use of the "Parameters" field, where you can access properties even during the deferred stage of the installation process.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
unal.akyuz
Posts: 1
Joined: Thu Dec 03, 2020 2:38 pm

Re: Sending Parameters into Powershell script added as script from disk under custom action

Hello there,

Is this issue remain same? or there is way to run PS script from file with AI_GetMsiProperty parameter now?

Thank you
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Sending Parameters into Powershell script added as script from disk under custom action

Hello and welcome to our forums,

Yes, the behavior is still the same.

If you want to retrieve the value of custom properties in your PowerShell script during the "Deferred" stage, then the "PowerShell Script Inline" custom action would be required.

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

Return to “Common Problems”