Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to obtain and modify the execution permission of powershell script

Shulou Source: shulou.com Published: 2022-06-02 05:41:34 11月15日 Update

By default, Windows server 2008R2's script execution permission is RemoteSigned, locally created scripts can be run, and downloads from the network must have a digital signature before they can be executed. In the course of actual use, users may encounter the phenomenon that the script cannot be executed. Here is a little discussion on the execution authority of the script, you can test it, welcome to leave a message for discussion.

Get the script execution permission policy for the current session:

PS D:\ powershell_study > Get-ExecutionPolicyRemoteSigned

Powershell has four script run permission policies, which can be viewed by the command man Set-ExecutionPolicy.

PS D:\ powershell_study > man Set-ExecutionPolicyNAME Set-ExecutionPolicySYNOPSIS Changes the user preference for the Windows PowerShell execution policy.SYNTAX Set-ExecutionPolicy [- ExecutionPolicy] {Unrestricted | RemoteSigned | AllSigned | Restricted | Default | Undefined} [[- Scope] {Process | CurrentUser | LocalMachine | UserPolicy | MachinePolicy}] [- Confirm] [- Force] [- WhatIf] [].

Unrestricated means unlimited, AllSigned means all scripts need digital signature verification, and Restricted means no script execution.

How to set the permissions for running the script:

PS C:\ > Set-ExecutionPolicy-ExecutionPolicy RemoteSigned

Tags: Scripts permissions runs meaning numbers digital signatures policies can be passed commands facts situations ways phenomena users networks procedures tests restrictions verification Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MySQL NVidia Shulou Tech Info MariaDB