Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, April 6, 2016 1:22 PM | 1 vote
Hi,
I have a powershell script and I don't want to change the ExecutionPolicy on my machine. When I run PS command line and type the following command:
powershell -ExecutionPolicy ByPass -File test.ps1
the script will run but I dont know how to add this command into my powershell script because I want to run it from context(linke in image) menu when I right click on this powershell script.

All replies (9)
Wednesday, April 6, 2016 4:50 PM ✅Answered
You would need to create a custom shell item that adds the bypass.
Search for articles on creating shell commands in File Explorer.
\(ツ)_/
Wednesday, April 6, 2016 4:51 PM ✅Answered
Here is one: http://www.howtogeek.com/107965/how-to-add-any-application-shortcut-to-windows-explorers-context-menu/
\(ツ)_/
Wednesday, April 6, 2016 1:33 PM | 1 vote
Good Day
As far as i remember you need to change the extension of your .cmd or .bat file to .ps1 in order to have that link enabled
Or you can also choose powershell to open .bat or .cmd files from default programs
Regards
Thursday, April 7, 2016 7:08 AM
I guess I have wirte a wrong question, but anyway - I have already scpirt and ability to run it from context menu but it don't execute because of executionpolicy.
All I want is to include in my script command:
powershell -ExecutionPolicy ByPass -File test.ps1
but I don't know how to do it.
Thursday, April 7, 2016 7:08 AM
I guess I have wirte a wrong question, but anyway - I have already scpirt and ability to run it from context menu but it don't execute because of executionpolicy.
All I want is to include in my script command:
powershell -ExecutionPolicy ByPass -File test.ps1
but I don't know how to do it.
Thursday, April 7, 2016 9:38 AM
Hi,
Thanks for the post. Do you mean:
PowerShell.exe -ExecutionPolicy Bypass -File .test.ps1
Also you can check below link for 15 ways to bypass powershell excution policy:
https://blog.netspi.com/15-ways-to-bypass-the-powershell-execution-policy/
Hope it helps.
Best Regards,
Elaine
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected].
Thursday, April 7, 2016 10:43 AM
HI,
thank you but do you know how can I include those commands in my PS script? In .ps1 file. I don;t want to run it from command line but only by right clicking on this script.
Thursday, April 7, 2016 12:12 PM
HI,
thank you but do you know how can I include those commands in my PS script? In .ps1 file. I don;t want to run it from command line but only by right clicking on this script.
You can't unless you follow jrv's suggestion.
Thursday, September 5, 2019 12:25 AM
Another option is to create a shortcut that contains the arguments:
%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -File "FilePath" -ExecutionPolicy Bypass