简体   繁体   中英

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

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"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM