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 information, a value, or an action supplied to a system, program, or computation 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 unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
shell scriptpart of · A shell script is a text program containing commands interpreted and executed by a command-line shell.
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.