Powershell supports three types of brackets.
Parenthesis brackets. − ()
Braces brackets. − {}
Square brackets. − []
This type of brackets is used to
pass arguments
enclose multiple set of instructions
resolve ambiguity
create array
> $array = @("item1", "item2", "item3") > foreach ($element in $array) { $element } item1 item2 item3
This type of brackets is used to
enclose statements
block commands
$x = 10 if($x -le 20){ write-host("This is if statement") }
This will produce the following result −
This is if statement.
This type of brackets is used to
access to array
access to hashtables
filter using regular expression
> $array = @("item1", "item2", "item3") > for($i = 0; $i -lt $array.length; $i++){ $array[$i] } item1 item2 item3 >Get-Process [r-s]* Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 320 72 27300 33764 227 3.95 4028 SCNotification 2298 77 57792 48712 308 2884 SearchIndexer ...