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.
- 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
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?