Tommy K
Tommy K

Reputation: 1807

How can I bypass execution policy when running scripts from Powershell ISE

So I can write a script in Powershell ISE, not save it, and it will run (F5/green arrow on the ISE). Once I save it, I get the error saying I can't run saved scripts. If I open a Powershell window in the directory the saved script exists, I can run it with

powershell -ExecutionPolicy ByPass -File script.ps1

But is there a way I can get this to work when running it via the ISE's green arrow/F5? I don't have admin access to this PC

Edit: Windows 10

Upvotes: 4

Views: 11810

Answers (2)

hotenov
hotenov

Reputation: 1143

Also you can run individual script without setting Execution Policy for current user, by passing Execution Policy only for file script.

For example:

Powershell -executionpolicy RemoteSigned -File "C:\scripts\script.ps1"

Very convenient for scheduled tasks in the Windows Task Scheduler to run PowerShell commands (scripts).

That's my addition for google users

Upvotes: 2

Tommy K
Tommy K

Reputation: 1807

Ok so I just found out you can set Execution Policy for yourself (current user) without having admin rights. So if you're coming here from google do this:

Set-ExecutionPolicy -Scope "CurrentUser" -ExecutionPolicy "RemoteSigned"

Upvotes: 11

Related Questions