Share via


Range Operators in PowerShell

What is Range Operators in PowerShell?

PowerShell Range Operator (..), combined with two pipeline processing.

help about_Operators

SEE ALSO
**about_Arithmetic_Operators
about_Assignment_Operators
about_Comparison_Operators
about_Logical_Operators
about_Type_Operators

**Many tricks can be played using range operators - refer this link

**Let me show another cool trick
**

$arr = 1..10
$arr[2]

returns 3 - Benefits no need to type type numbers in arrays or other way we can avoid loops.

Can we add additional values in this array - Yes we can using assignment operator "+="

$arr += @(11)
$arr[10]

returns 11 - Array start from 0.

Enjoy PowerShell!!!