0

So i wrote a small VB Program, which runs a powershell script. I know that my ExecutionPolicy has to be set on RemoteSigned or Unrestricted in order to execute scripts on my Computer. So that's what i did, but it keeps on saying ... cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at .. bla bla Normally this problem is solved by changing the ExecutionPolicy, but not this time. Maybe because i call powershell out of an EXE? Idk.

Some advise?

0

Try to run it this way:

powershell.exe -ExecutionPolicy Bypass yourScript.ps1

Explanation:

From the documentation:

-ExecutionPolicy

Specifies the new execution policy. The acceptable values for this parameter are:

  • Restricted. Does not load configuration files or run scripts. Restricted is the default execution policy.
  • AllSigned. Requires that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the local computer.
  • RemoteSigned. Requires that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher.
  • Unrestricted. Loads all configuration files and runs all scripts. If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs.
  • Bypass. Nothing is blocked and there are no warnings or prompts.
  • Undefined. Removes the currently assigned execution policy from the current scope. This parameter will not remove an execution policy that is set in a Group Policy scope.
  • ah sure, i forgot to mention, sry for that. I also tried bypass and this kind of stuff. – arvenyon Dec 14 '17 at 10:26
  • Did you also try to permanently allow scripts for your user by running (once) Set-Executionpolicy -Scope CurrentUser -ExecutionPolicy Bypass? – hanjo Dec 14 '17 at 10:30
  • I did, not helping tho. But I just found the solution by accident... I opened the powershell.exe directly from directory with admin rights, and then loaded the PSReadLine Module manually. This helped me out and everything works now perfeclty. But thank you anyway for your help! – arvenyon Dec 14 '17 at 10:41
  • @arvenyon Post and accept your solution once you're able to. – root Dec 14 '17 at 21:00
0

Okay, so after endless trying I accidentally found the solution. Or, I'd better say.. it worked for me.

I started the powershell.exe out of it's root directory with admin rights. Afterwards i loaded the PSReadLine Module manually and set the ExecutionPolicy again on RemoteSigned.

After these steps, everything worked as expected. To be honest, I don't see the difference right now between opening powershell out of the start menu with admin rights and opening it out of it's root directory with admin rights. But it made the difference. Interesting.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.