Search notes:

PowerShell: The Preference Variable $PSDefaultParameterValues

The PowerShell preference variable $psDefaultParameterValues allows to define default values with which cmdlet parameters are assigned when a given cmdlet is invoked.
$psDefaultParameterValues is a hash table (or more accurately an instance of System.Management.Automation.DefaultParameterDictionary). Such a hash table allows to store key/value pairs.
The values that are defined in $psDefaultParameterValues customize cmdLets and advanced functions only, but not scripts or simple functions.
$psDefaultParameterValues has no default values. Typically, the values for the $psDefaultParameterValues variable are set in the profile (see $profile).

Format of keys and values

Keys

The format of the keys in in $psDefaultParameterValues is cmdletName:parameterName.
Both, cmdletName and parameterName can contain wildcard characters.

Values

A value is either a string which sets the matched parameter's default value or a script block.

Simple example

Setting the key *:encoding to utf8 will cause the parameter -encoding to be set to utf8 when invoking any cmdlet with an -encoding parameter:
$psDefaultParameterValues['*:encoding'] = 'utf8'

Disabling psDefaultParameterValues

The values of $psDefaultParameterValues can be temporarily disabled by adding a key whose name is Disabled and a value whose value is $true.
Setting this value to $false enables using of $psDefaultParameterValues again.

Index