The Set-ExecutionPolicy cmdlet enables you to determine which Windows PowerShell scripts (if any) will be allowed to run on your computer. Windows PowerShell has four different execution policies:
- Restricted – No scripts can be run. Windows PowerShell can be used only in interactive mode.
- AllSigned – Only scripts signed by a trusted publisher can be run.
- RemoteSigned – Downloaded scripts must be signed by a trusted publisher before they can be run.
- Unrestricted – No restrictions; all Windows PowerShell scripts can be run.
But, automating certain sequences, you may not want to modify the current execution policy. To launch scripts in an elevated status, without changing the policy, you can run the following—which points to your script
powershell -ExecutionPolicy ByPass -File YourScript.ps1
Powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File “YourScript.ps1”
Powershell -noprofile -executionpolicy bypass -file “YourScript.ps1”