Reputation: 27008
Is anyone know how to get my ps2exe.ps1 to be execute?? I got this exception and no clue to solve it.
PS C:\> Set-ExecutionPolicy RemoteSigned
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks desc
about_Execution_Policies help topic. Do you want to change the execution policy?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
PS C:\> .\ps2exe.ps1
File C:\ps2exe.ps1 cannot be loaded. The file C:\ps2exe.ps1 is not digitally signed. The script will not execute on the system. Please see "get-help
At line:1 char:13
+ .\ps2exe.ps1 <<<<
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
Upvotes: 0
Views: 5372
Reputation: 54971
The ExeutionPolicy RemoteSigned
allows running of local scripts(created on your computer) and signed scripts from other locations. Since your scripts is downloaded from the internet, it has a "block"-attribute associated with it.
To fix this, open Properties
for the ps1-file, click Unblock
and Apply/OK
.
Or you could set the executionpolicy to Unrestricted
if you want to allow everything(not recommended).
It may be worth mentioning that signed scripts will prompt for confirmation before execution unless you already have the specific publishers certificate installed in Trusted Publishers certificate store.
Upvotes: 4