PowerShell Tutorial
Selected Reading
- PowerShell - Discussion
- PowerShell - Useful Resources
- PowerShell - Quick Guide
- PowerShell - Alias
- PowerShell - Brackets
- PowerShell - Backtick
- PowerShell - Regex
- PowerShell - Hashtables
- PowerShell - Array
- PowerShell - Conditions
- PowerShell - Looping
- PowerShell - Operators
- PowerShell - Special Variables
- PowerShell - Scripting
- PowerShell - Advanced Cmdlets
- PowerShell - Files I/O
- PowerShell - Dates and Timers
- PowerShell - Files and Folders
- PowerShell - Cmdlets
- PowerShell - Environment Setup
- PowerShell - Overview
- PowerShell - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
PowerShell - Brackets
Powershell - Brackets
Powershell supports three types of brackets.
Parenthesis brackets. − ()
Braces brackets. − {}
Square brackets. − []
Parenthesis brackets
This type of brackets is used to
pass arguments
enclose multiple set of instructions
resolve ambiguity
create array
Example
> $array = @("item1", "item2", "item3") > foreach ($element in $array) { $element } item1 item2 item3
Braces brackets
This type of brackets is used to
enclose statements
block commands
Example
$x = 10 if($x -le 20){ write-host("This is if statement") }
This will produce the following result −
Output
This is if statement.
Square brackets
This type of brackets is used to
access to array
access to hashtables
filter using regular expression
Example
> $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 ...Advertisements