Execute Powershell Script from a EXE... Executionpolicy RemoteSigend/Unrestricted, still failing

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?

arvenyon

Posted 2017-12-14T09:52:15.957

Reputation: 45

Answers

1

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.

arvenyon

Posted 2017-12-14T09:52:15.957

Reputation: 45

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.

hanjo

Posted 2017-12-14T09:52:15.957

Reputation: 491

ah sure, i forgot to mention, sry for that. I also tried bypass and this kind of stuff. – arvenyon – 2017-12-14T10:26:53.473

Did you also try to permanently allow scripts for your user by running (once) Set-Executionpolicy -Scope CurrentUser -ExecutionPolicy Bypass? – hanjo – 2017-12-14T10:30:50.653

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 – 2017-12-14T10:41:47.627

@arvenyon Post and accept your solution once you're able to. – root – 2017-12-14T21:00:50.627