I am trying to run a cmd
file that calls a PowerShell script from cmd.exe
, but I am getting this error:
Management_Instal
Also running this command before the script also solves the issue:
set-executionpolicy unrestricted
In PowerShell 2.0, the execution policy was set to disabled by default.
From then on, the PowerShell team has made a lot of improvements, and they are confident that users will not break things much while running scripts. So from PowerShell 4.0 onward, it is enabled by default.
In your case, type Set-ExecutionPolicy RemoteSigned
from the PowerShell console and say yes.
Go to the registry path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
and set ExecutionPolicy
to RemoteSigned
.
This solved my issue
Open Windows PowerShell
Command and run below query to change ExecutionPolicy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
if it ask for confirm changes press 'Y' and hit enter.
Setting the execution policy is environment-specific. If you are trying to execute a script from the running x86 ISE you have to use the x86 PowerShell to set the execution policy. Likewise, if you are running the 64-bit ISE you have to set the policy with the 64-bit PowerShell.