February 2019
Intermediate to advanced
626 pages
15h 51m
English
Parameters may be given default values by using assignment statements in the param block, such as the following, for example:
param ( [String]$Parameter1 = 'DefaultValue')
If the assignment is the result of a command, the command must be placed in parentheses:
param ( [String]$ProcessName = (Get-Process -Id $PID | Select-Object -ExpandProperty Name))
Value types, such as Boolean, or Int32 and other numeric types, are initialized with a default value for that type. For instance, a parameter of the Boolean type can never be null; it will default to false. Numeric values will default to 0. Setting a default false value for a Boolean parameter is therefore unnecessary.
Assigning a default value was the basis for making parameters ...
Read now
Unlock full access