Param block
A parameter block is a PowerShell construct that declares a script or function’s parameters, default values, and related metadata.
Practical Automation with PowerShell: Effective scripting from the console to the cloud
A parameter block is the section of a PowerShell function or script that declares its input parameters and their metadata.
- How it is used
- Defines the required and optional inputs that drive reusable archive and log-cleanup automations.
- How deep it goes
- Explains placement, mandatory flags, types, and defaults through complete function and script listings.
- Examples
- Demonstrates archive-path inputs, a date parameter, and a 30-day log-retention setting in a cleanup script.
- What you can do after
- Apply it via PowerShell functions and scripts to declare typed, required, and optional automation inputs.
Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS
A param block is a PowerShell language construct that declares the parameters and default values of a script or function.
- How it is used
- Turns hardcoded script values into inputs for repeatable administrative commands.
- How deep it goes
- Explains declarations, defaults, invocation forms, types, mandatory attributes, and block punctuation through working scripts.
- Examples
- Uses Get-DiskInventory with computer-name and drive-type parameters, including mandatory prompting and typed values.
- What you can do after
- Apply it via PowerShell scripts to replace hardcoded values with named, positional, defaulted, or mandatory inputs.
Related concepts
- inputhas part · An input is a value, information, or signal supplied to a system, computation, or interface for processing or to influence its behavior.
- CmdletBinding attributehas part · The CmdletBinding attribute is a PowerShell declaration that enables cmdlet-like behavior and advanced features for a script or function.
- functionpart of · A function is a callable program unit that performs an operation, may accept inputs, and can produce a result or side effect.
- shell scriptpart of · Bash is a Unix command-line shell and scripting language for executing commands interactively and through scripts.
- script parametersconfigures · Script parameters are named values supplied separately from script source and made available to the script at execution time.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

