0

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
3
  • 1
    is this script you created locally or download from internet? Commented Nov 1, 2013 at 9:23
  • download from internet Commented Nov 1, 2013 at 10:06
  • according to this page:technet.microsoft.com/en-us/library/ee176961.aspx, Downloaded scripts must be signed by a trusted publisher before they can be run. Maybe you should set policy to Unrestricted temporarily to make this script to run Commented Nov 1, 2013 at 10:08

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't like windows has so many strange rules!! anyways thx!
It's not that strange really. Powershell uses the standard windows rule where executing remote files gives you a warning if they come from untrusted sources(not in Trusted Sites list in Internet Explorer). Opening network files gives you a Run/cancel prompt for the same reason. :-)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.