Inline Powershell Script - unauthorized access error - Advanced Installer Community
kmauzoul
Posts: 11
Joined: Thu Jul 23, 2020 3:50 pm

Inline Powershell Script - unauthorized access error

Hello -

I have a simple inline powershell script that I am running to get the fully qualified domain name:

Code: Select all

$myFQDN=(Get-WmiObject win32_computersystem).DNSHostName+"."+(Get-WmiObject win32_computersystem).Domain
AI_SetMsiProperty FQDN $myFQDN
However, I'm met with this error in the logs -

Code: Select all

POWERSHELL_EXECUTION_LOG = File C:\Users\synergy\AppData\Local\Temp\pss1CEB.ps1 cannot be loaded. The file 
C:\Users\synergy\AppData\Local\Temp\pss1CEB.ps1 is not digitally signed. You cannot run this script on the current 
system. For more information about running scripts and setting execution policy, see about_Execution_Policies at 
https:/go.microsoft.com/fwlink/?LinkID=135170.
    + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnauthorizedAccess
I read somewhere earlier that in line scripts are ran with Bypass turned on so I'm not sure why any in line power shell script I try to run returns that error from the installer.

This install is being built with version 20.0

Any help would be greatly appreciated.
Liviu
Posts: 1419
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Inline Powershell Script - unauthorized access error

Hello,

As the error suggest, the execution of unsigned PowerShell scripts is blocked on this machine.

It seems that, on this machine, the PowerShell execution policies are set to "AllSigned".

Can you please sign your PowerShell script? Just click on the "PowerShell Script Options" option and make sure the "Digitally sign the script" option is checked.
powershell sign.png
powershell sign.png (82.14 KiB) Viewed 4927 times

Also, you need to sign your installer in the Digital Signature page with a certificate from a trusted vendor. If using a self-generated signing certificate, you have to make sure the certificate is placed in Trusted Root Certification or Trusted Publishers stores on the machine. If the certificate is missing from the above stores, the digital signature is not recognized and the execution of a signed script on a machine with restricted policy will fail.

Hope this helps!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”