A param block is a PowerShell language construct that declares the parameters and default values of a script or function.
A param block turns changing script values into command-line inputs. It can assign defaults, so a script works without every value being supplied. section 19.4
Use a param block to:
Declare one or more parameters, separated by commas. section 19.4
Accept values positionally or by name, including abbreviated names. section 19.4
Add data types, mandatory behavior, and parameter attributes. section 20.3
Disk inventory parameters
param ( $computername = 'localhost', $drivetype = 3 ) lets the script query the local computer by default. Run .\Get-DiskInventory.ps1 SRV1 3, or omit either value to use its default. section 19.4
Listing 19.3 Get-DiskInventory.ps1, with an input parameter
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.
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.