about_Execution_Policies

时间:2022-10-22 09:21:32

https://technet.microsoft.com/en-us/library/hh847748.aspx?f=255&MSPPError=-2147217396

在powershell中执行命令

Get-ExecutionPolicy -List

此命令也可以使用tab键进行辅助

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined

查询指定的Scope的ExecutionPolicy

Get-ExecutionPolicy -Scope CurrentUser

Get-ExecutionPolicy CurrentUser

CHANGE YOUR EXECUTION POLICY
------------------------------
To change the Windows PowerShell execution policy on your
computer, use the Set-ExecutionPolicy cmdlet. The change is effective immediately; you do not need to restart
Windows PowerShell. If you set the execution policy for the local computer (the default)
or the current user, the change is saved in the registry and remains
effective until you change it again. If you set the execution policy for the current process, it is
not saved in the registry. It is retained until the current
process and any child processes are closed. Note: In Windows Vista and later versions of Windows, to run
commands that change the execution policy for the local
computer (the default), start Windows PowerShell with the
"Run as administrator" option. To change your execution policy, type: Set-ExecutionPolicy -ExecutionPolicy <PolicyName> For example: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned To set the execution policy in a particular scope, type: Set-ExecutionPolicy -ExecutionPolicy <PolicyName> -Scope <scope> For example: Set-ExecutionPolicy RemoteSigned -Scope CurrentUser A command to change an execution policy can succeed but
still not change the effective execution policy. For example, a command that sets the execution policy for
the local computer can succeed but be overridden by the
execution policy for the current user.

示例:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

设置完成后,可以用上面的命令进行查看