liveBook · Manning

-ExecutionPolicy

As explained in Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

-ExecutionPolicy is a PowerShell startup parameter that specifies an execution policy for the launched session.

-ExecutionPolicy is a PowerShell startup parameter that specifies the execution policy for the launched session. It can override both local and Group Policy settings. section 4.1.1

Use the parameter when you need to:

  • Launch PowerShell with a specified execution policy instead of changing the machine-wide setting. section 4.1.1
  • Work around a local or Group Policy-defined setting for that launched session. section 4.1.1

Launching with an execution policy

Run PowerShell.exe with the -ExecutionPolicy command-line switch and the desired policy value. Unlike Set-ExecutionPolicy, this startup choice overrides local and Group Policy settings. section 4.1.1

File C:\Scripts\Get-DiskInventory.ps1 cannot be loaded because the execution 
 of scripts is disabled on this system. Please see "get-help about_signing"
 for more details.

Use the script-loading error to recognize when the current execution policy prevents scripts from running. section 4.1.1

How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it

How deep it goes
Explains policy precedence and contrasts the startup switch with Set-ExecutionPolicy and Group Policy, without detailing every policy value.
Examples
Uses a script-loading error and contrasts startup configuration with Set-ExecutionPolicy.
What it assumes
Assumes familiarity with launching PowerShell and introduces execution policy as a script-security setting.
What you can do after
Operate/configure a launched PowerShell session with a policy that overrides local and Group Policy settings.
How it connects
Connects execution policy with PowerShell.exe, Set-ExecutionPolicy, Get-ExecutionPolicy, Group Policy, and the Windows Registry.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.