Precedence, grouping, and sub-expressions
Each operator in PowerShell is given a precedence, an order in which it will be evaluated.
The operators used in this section are explored during this chapter.
Operator precedence
Operations are executed in a specific order depending on the operator used. For example, consider the following two simple calculations:
3 + 2 * 2
2 * 2 + 3
The result of both preceding expressions is 7 (2 multiplied by 2, and then add 3) because the multiplication operator has higher precedence than the addition operator.
Where operator precedence is equal, the expression is evaluated from left to right.
PowerShell includes a help document describing the precedence for each operator. The precedence list is long and not duplicated in this chapter:
Get-Help about_Operator_Precedence
The online version of the same document is available at Microsoft Learn:
The help topic...