Powershell Tip : Run a ps1 without changing the executionpolicy rules


In order to run a powershell script (.ps1) on a computer, you have to change the executionpolicy rules. 


To see which policy is applied on your computer you type " set-executionpolicy " on the powershell prompt.

By default this policy is set to " Restricted ".


If you want to change it you have to type " set-executionpolicy remotesigned ", as an example.





To avoid changing this policy, you can run your ps1 using the below commandline.

c:\Windows\system32\WindowsPowershell\v1.0\powershell.exe -stan -WindowStyle Hidden -noprofile -executionpolicy bypass -file "name of your ps1file.ps1"

Share this

Related Posts

Previous
Next Post »