Creating Numeric Ranges

by Feb 16, 2009

There is a clever trick in PowerShell to create numeric ranges that you probably know:


But did you know you can use variables with this trick? Try this:

$start = 100
$stop = 200

Let's say you defined an array and want to return all elements except the first one. Here is a way to do it:

$array = 1..10