Quantcast
Channel: SAPIEN Forums
Viewing all articles
Browse latest Browse all 311

PowerShell • Running a script during MSI install

$
0
0
I hope this is the right section to post this in.
I'm having trouble running a script successfully during the MSI installation process.

My goal is to import a set of modules as a custom action during installation. The primary module (VMware.PowerCLI) includes scripts which are blocked by execution policy by default. I have tried building with a packaged exe, and I have tried building with a ps1 and checking the "Use execution policy bypass", neither seem to work.

Code:

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force -Confirm:$false
Import-Module VMware.PowerCLI
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false > $null
Set-PowerCLIConfiguration -Scope AllUsers -ParticipateInCeip $false -Confirm:$false > $null
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name CertificateRevocation -Value 0 > $null
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust Providers\Software Publishing" -Name State -Value 146944 > $null
The script contents:
1. Bypass execution policy temporarily, the installer is run with Admin privileges.
2. The module import.
3-4. Two module settings that are available after the import
5-6. Two reg settings that speed up module load times, these are on isolated networks.

After the MSI installer runs, I can see that the registry entries have been applied but the module was never successfully imported.
If I manually bypass execution policy and then manually run the script, the module imports.

Any ideas for making it successfully run with the installer?

Statistics: Posted by akontokanis — Mon Mar 04, 2024 11:26 am — Replies 0 — Views 406



Viewing all articles
Browse latest Browse all 311

Trending Articles