官术网_书友最值得收藏!

Modifying the PowerShell execution policy

If this is the first time that you are using Windows PowerShell on the computer on which you installed PowerCLI, you have to change the execution policy to be able to start PowerCLI.

The Windows PowerShell execution policies define when you can run scripts or load configuration files. The possible values for the execution policy are: Restricted, AllSigned, RemoteSigned, Unrestricted, Bypass, and Undefined.

You can check the current execution policy setting with the following command:

PowerCLI C:\> Get-ExecutionPolicy

Get-ExecutionPolicy is a Windows PowerShell commandlet (cmdlet). Cmdlets are commands built into PowerShell or PowerCLI. They follow a verb-noun naming convention. The get cmdlets receives information about the item that is specified as the noun part of the cmdlet.

Set the execution policy to RemoteSigned to be able to start PowerCLI and run scripts written on the local computer with the Set-ExecutionPolicy –ExecutionPolicy RemoteSigned command, as shown in the next screenshot.

Note

You have to run the Set-ExecutionPolicy –ExecutionPolicy RemoteSigned command from a PowerShell or PowerCLI session that you started using the Run as Administrator option, or you will get the following error message:

Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied.

If you are using both the 32-bit and the 64-bit versions of PowerCLI, you have to run this command in both versions.

In the next screenshot of the PowerCLI console, you will see the output of the Set-ExecutionPolicy –ExecutionPolicy RemoteSigned command if you run this command in a PowerCLI session started with "Run as Administrator".

Modifying the PowerShell execution policy

You can get more information about execution policies by typing the following command:

PowerCLI C:\> Get-Help about_Execution_Policies

To get more information about signing your scripts, type the following command:

PowerCLI C:\> Get-Help about_signing
主站蜘蛛池模板: 独山县| 栾川县| 隆安县| 淮安市| 南丰县| 宣恩县| 方城县| 永康市| 安图县| 都匀市| 开封市| 积石山| 郴州市| 广宁县| 太原市| 台前县| 贺兰县| 八宿县| 绩溪县| 崇信县| 铜鼓县| 加查县| 清水县| 尤溪县| 锦屏县| 凤冈县| 北票市| 剑河县| 桓仁| 石城县| 荥阳市| 沂源县| 金门县| 承德县| 宜黄县| 崇仁县| 阜宁县| 淳安县| 远安县| 太康县| 柏乡县|