Pages

Showing posts with label PnP PowerShell. Show all posts
Showing posts with label PnP PowerShell. Show all posts

Wednesday, June 26, 2024

Set-ExecutionPolicy

 The Set-ExecutionPolicy cmdlet change the user preference for the Windows PowerShell execution policy.


Set-ExecutionPolicy [-ExecutionPolicy*] {Unrestricted | RemoteSigned | AllSigned | Restricted | Default | Bypass |Undefined} [[-Scope] {Process | CurrentUser | LocalMachine | UserPolicy | MachinePolicy}] [-Confirm] [-Force][-WhatIf] [<CommonParameters>]


Examples

Set the shell execution policy:


PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned


The command uses the Force parameter to suppress the user prompt.


Set the scope for an execution policy:


PS C:\> Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy AllSigned -Force

PS C:\> Get-ExecutionPolicy -List



Remove the execution policy for the current user:


PS C:\> Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Undefined

Other Issues:

When you run an .ps1 PowerShell script you will get the message saying “.ps1 is not digitally signed. The script will not execute on the system.”


To fix this issue you have to run the following command to run Set-ExecutionPolicy and change the Execution Policy setting.


Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass