liveBook · Manning

Switch parameter

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

A switch parameter is a Boolean-style command parameter whose presence enables an option without requiring an input value.

A switch parameter turns an option on simply by appearing in a command. It accepts no input value, so typing the parameter name is enough. section 3.5.4 section 4.3

Remember these practical rules:

  • Type the parameter name, or an accepted abbreviation; switches are never positional. section 3.5.4
  • Choose whether to include the switch because switches are optional. section 3.5.4
  • Keep the dash attached to the parameter name and separate parameters with spaces. section 4.3

Including hidden items

Get-Item .* lists no files in the described case, while Get-Item .* -Force tells the command to include items beginning with ., which are treated as hidden. The -Force parameter needs no value. section 3.5.4

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

How deep it goes
Explains syntax, optionality, positional rules, and a hidden-file example, without descending into implementation details.
Examples
Demonstrates Get-Item .* with and without -Force, contrasting ordinary retrieval with hidden-item inclusion.
What it assumes
Assumes basic PowerShell command entry while clarifying parameter names, dashes, spaces, and values.
What you can do after
Apply it via PowerShell by recognizing switches and adding options such as -Force without supplying values.
How it connects
Connects switch parameters with cmdlets, named parameters, command syntax, and hidden items.

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.