Problem:
This error comes when the PowerShell execution policy doesn’t allow us to run scripts. I also found the same error when tried to run a PowerShell script.
Advertisement
Solution:
The PowerShell execution policy is default set to Restricted. You can change the PowerShell execution policies with Set-ExecutionPolicy
cmdlet. To run outside script set policy to RemoteSigned.
PS C:\> Set-ExecutionPolicy RemoteSigned
Below is the list of four different execution policies in PowerShell
- 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.
You Should Also Know:
Run the following command to get current execution policy in set in PowerShell.
PS C:\> get-executionpolicy
You can bypass this policy by adding -ExecutionPolicy ByPass
when running PowerShell script.
c:\> powershell -ExecutionPolicy ByPass -File script.ps1
Reference: https://technet.microsoft.com/en-us/library/ee176961.aspx
17 Comments
Thanks for the tutorial
I tried to write the command and the response was:
‘Set-ExecutionPolicy’ is not recognized as an internal or external command,
executable program or batch file.
Very good website my problem is solution
Thanks it worked
This fixed it for me on Windows 10 running in Parallels on a Macbook. Thanks for sharing this, a great help!
tnx dude it helps
Mine didn’t work. This is the error
Get-Process : A positional parameter cannot be found that accepts argument ‘Set-ExecutionPolicy’.
At line:1 char:1
+ PS C:\> Set-ExecutionPolicy RemoteSigned
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Process], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetProcessCommand
Run as admin; that should do it
same error with admin
You are using Get-Process ? May we see your full command?
All you should be entering is:
Set-ExecutionPolicy RemoteSigned
verry verrrrrrrrryyyyyyyyyyyyyyyyy helpful
thnaks
Thanks for your explanation about PS policy, It help me alot.
thanks it worked for me
how we can on window 10 plz tell me step by step
Hi,
please just notice that it need to be set separately for x86 and x64 versions of powershell.
Hi,RAHUL
Thank You So Much For PowerShell – Running scripts is disabled on this system. You Explanation is good.
will this script work on windows 7 ?
yes it will