A default value supplies a parameter automatically when someone omits that input. In PowerShell, a Param() declaration can give a script parameter a practical fallback such as localhost. section 19.4
Disk inventory with an optional computer name
Declare $computername = 'localhost', then run .\Get-DiskInventory.ps1 without a computer name or provide one positionally or by name. Adding $drivetype = 3 lets either parameter be omitted independently. section 19.4
PowerShell also stores session-wide parameter defaults in $PSDefaultParameterValues. Values or script blocks can apply defaults to selected commands, while script-local settings remain scoped to that script. section 26.6
PS C:\> .\Get-DiskInventory.ps1 SRV1 3 PS C:\> .\Get-DiskInventory.ps1 -ComputerName SRV1 -drive 3 PS C:\> .\Get-DiskInventory.ps1 SRV1 PS C:\> .\Get-DiskInventory.ps1 -drive 3
Compare positional, abbreviated, and omitted parameters in runnable script calls. section 19.4



















