Two very little-known or little-used built-in variables are the PSDefaultParameterValues and PSBoundParameters dictionaries. Both serve a distinct purpose in scripting, and will make your life easier.
PSDefaultParameterValues and PSBoundParameters
PSDefaultParameterValues
Let's examine the first dictionary, PSDefaultParameterValues, in the following code sample:
# The automatic variable is great to set defaults
$labFolder = mkdir .\StagingDirectory -Force
$PSDefaultParameterValues = @{
'*:Path' = $labFolder.FullName # Extremely generic. Set all Path parameters for all Cmdlets
'New-Item:ItemType' = 'File'
}
# Notice how all cmdlets use Path
# New-Item uses ItemType File now
New-Item ...