Powershell Version 2 Problem - Advanced Installer Community
DominikW
Posts: 2
Joined: Thu Apr 09, 2026 9:53 am

Powershell Version 2 Problem

Hello,

I hope this is the correct board, otherwise please move it.

We recently had the issue that one of our customers wasn't able to run our setup properly because Powershell version 2 was blocked on their system.
All our Scripts have the #Requires -version 3 line right at the top so this should force it to be at least version 3.
We are using AdvancedInstaller Version 21.9 is there any internal system that's still trying to use version 2?
On Systems where Powershell version 2 isn't present at all the setup is running fine.

I hope this info is enough to help me.

Thank you very much in advance.
Catalin
Posts: 7847
Joined: Wed Jun 13, 2018 7:49 am

Re: Powershell Version 2 Problem

Hello Dominik and welcome to our forums,

Apologies for the quite delayed reply on this - we had some days off thanks to the Orthodox Easter.
All our Scripts have the #Requires -version 3 line right at the top so this should force it to be at least version 3.
This alone should make the script not require a version lower than 3, so not quite sure why that is happening.

Regarding the error, could you please give me some more details about it? For example, what is the error message you are receiving?

Have you checked the log file, or perhaps event viewer?
On Systems where Powershell version 2 isn't present at all the setup is running fine.
So if PS2 is not present at all, the setup works, but if PS2 is blocked, the setup does not work - is this what you are saying?

If possible, could you please let me know how your customer blocked PS2 on their system? Is it via a GPO? If so, could you please let me know which GPO exactly so I can try and tests this on our end?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
DominikW
Posts: 2
Joined: Thu Apr 09, 2026 9:53 am

Re: Powershell Version 2 Problem

Hello Catalin,

no worries.
After your request for more Information we got digging a bit deeper and figured out that Powershell 2 wasn't actually the issue but ConstrainedLanguageMode is.
Powershell 2 was something that we assumed.
We reworked our Powershell code to be CLM compliant, however it looks like the AI_SetMsiProperty or AI_GetMsiProperty calls are not. So our installer is still failing on Systems that have CLM enabled.

The actual log output that I can share looks like this

Code: Select all

MSI (c) (6C:E4) [15:31:05:664]: Doing action: ValidatePort
Action started at 15:31:05: ValidatePort.
MSI (c) (6C:D0) [15:31:05:664]: Invoking remote custom action. DLL: C:\Users\[USER]\AppData\Local\Temp\MSI914.tmp, Entrypoint: RunPowerShellScript
[INFO] PowerShell script preferred invocation folder: 
Dumping PowerShell invoke log ...
--> Found PowerShell path: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
--> PowerShell Script Execution Result Code: 574
--> PowerShell Script Execution log: 
ERROR: Cannot invoke method. Method invocation is supported only on core types in this language mode.
MSI (c) (6C!38) [15:31:07:216]: PROPERTY CHANGE: Adding POWERSHELL_EXECUTION_LOG property. Its value is 'ERROR: Cannot invoke method. Method invocation is supported only on core types in this language mode.'.
CustomAction ValidatePort returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended at 15:31:07: ValidatePort. Return value 3.
You can easily enable CLM with this small script for easier testing

Code: Select all

powershell -Command "[System.Environment]::SetEnvironmentVariable('__PSLockdownPolicy', '4', 'Machine')"
Best regards
Dominik
Catalin
Posts: 7847
Joined: Wed Jun 13, 2018 7:49 am

Re: Powershell Version 2 Problem

Hello Dominik,

I have tested this and can indeed confirm the behavior.

I have then checked our improvement tracking tool and noticed we already have a ticket opened regarding this (i.e. making the two cmdlets you mentioned CLM compatible).

Hopefully this will be integrated in a future version of Advanced Installer.

Until then, the only workaround would be to use a different type of custom action (such as a C# custom action).

Let me know if there is anything else I can help you with and I will gladly assist.

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

Return to “Common Problems”