PoshTip #25 – Get the PowerShell Execution Policy

PoshTip #25 – Get the PowerShell Execution Policy

One of the first steps is to correctly select the Execution Policy. Windows Powershell has six different execution policies to run a script. You can list them with the “Get-ExecutionPolicy” cmdlet :

Get-ExecutionPolicy -List
  • Restricted/Default:
    This is the default policy. You may not launch any script. The only possibility is to use PowerShell in ‘interactive mode’.
  • Allsigned:
    All the scripts that should be executed on the machine must be signed by a ‘Trusted Publisher’.
  • RemoteSigned:
    This concerns only the scripts that have been downloaded from the internet. These scripts must be signed by a ‘Trusted Publisher’.
  • Unrestricted:
    No constraints on the execution of scripts. All the scripts will be executed if you accept a warning message. I do not recommend it in a production environment.
  • Bypass:
    No blockage, no warning message. Everything is executed without control.
  • Undefined:
    Removes the currently assigned execution policy from the current scope. This parameter will not remove an execution policy that is set in a Group Policy scope.

Now If you want to know which Execution Policy has been selected on your machine, run the following cmdlet :

Get-ExecutionPolicy

 

Thanks for reading! You can follow me on Twitter @PrigentNico

About Nicolas 282 Articles
I work as an IT Production Manager, based in Paris (France) with a primary focus on Microsoft technologies. I have 10 years experience in administering Windows Servers. . I am a Microsoft MVP for Cloud & Datacenter Management. I also received the PowerShell Hero 2016 award by PowerShell.0rg. And finally, I am "MCSE: Cloud Platform and Infrastructure", "MCSA: Windows Servers", "Administering & Deploying SCCM", and CheckPoint CCSA certified.