Commandlet

About commandlet in PowerShell.

Try to use the cmdlet

The cmdlet has a naming convention of “Verb-Noun”.
This makes it somewhat understandable even for beginners.

This makes the command longer, but you can use the Tab key to complete the input.
Note that PowerShell is not case-sensitive.

PS> Get-ChildItem
PS> get-childitem

Specifying parameters

You can specify the behavior of the cmdlet with -parameter value.
Those without a parameter value are called switch parameters.

PS> Get-ChildItem -Recurse

Explicitly enable/disable parameters

You can explicitly enable/disable a parameter by using the :.

# Commandlet -Parameter:Value
PS> Get-ChildItem -Recurse:$true
PS> Get-ChildItem -Recurse:$false

Specifying multiple parameters

Multiple parameters can be specified.
If the parameters are explicitly specified, the order can be changed.

PS> Commandlet -Parameter1 Value1 -Parameter2 Value2
PS> Commandlet -Parameter2 Value2 -Parameter1 Value1

Multiple values can be specified for a single parameter, separated by commas.

PS> Get-Process -Name explorer,outlook

Parameter Abbreviation

Some parameter names can be abbreviated if they do not conflict with other parameters.

Example: When -Recurse is abbreviated

PS> Get-ChildItem -r

Parameter specification using splatting symbols

Using the splitting symbol @,
parameter names and parameter values can be stored in an associative array and reused.

This can be used to pass the parameters received by a function to another function or cmdlet within that function.

PS> notepad
PS> $param = @{Name="notepad"}
PS> Get-Process @param
PS> Stop-Process @param

YouTube

Click here for a video explanation.