-
Parameters provide required inputs to Cmdlets if needed. Few CmdLets do not require any inputs few have mandatory parameters
-
Paremeters are provided using a
-
hyphon i.e.Any-Cmdlet -Parameter1 -Parameter2
-
Parameter values are supplied through a
<space>
char. -
Example of such parameter is
Get-Process -Name svchost
here-Name
is a Parameter and 'svchost' is its value. -
If you use a
Get-Help
and see the syntax section, you will see a list of parameters which you can supply to given CmdLet
- If you directly supply parameter without using
-ParameterName
the first positional parameter will be considered as default
- Single-Value Vs Multi-Value Parameter | Notice
<string>
vs<string[]>
- Help shows Parameter data type.
<string>
is a single string i.e. Single Value can be supplied.<string[]>
is an array of strings i.e. Multiple string values can be supplied- Example
Test-Connection -ComputerName 127.0.0.1 10.0.0.1
here -ComputerName parameter is<string[]>
type hence two IPs are supplied as input
- What and How many are these CommonParameters ?
The common parameters are:
-Verbose
-Debug
-WarningAction
-WarningVariable
-ErrorAction
-ErrorVariable
-OutVariable
-OutBuffer
The risk mitigation parameters are:
-WhatIf
-Confirm