The PowerShell execution policy is default set to Restricted. You can change the PowerShell execution policies with the
Set-ExecutionPolicy cmdlet. Only members of the dministrators group on the computer can change the execution policy. So, Start Windows PowerShell with the "Run as Administrator" option. and run below command with the desired execution policy option.
PS D:\pstest> Set-ExecutionPolicy RemoteSigned
- Restricted – No scripts can be run.
- AllSigned – Only scripts signed by a trusted publisher can be run.
- RemoteSigned – Downloaded scripts must be signed by a trusted publisher.
- Unrestricted – All Windows PowerShell scripts can be run
PS D:\pstest> Get-ExecutionPolicyRestricted
PS D:\pstest> powershell -ExecutionPolicy ByPass -File test.ps1