Creating Numeric Ranges

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

1..10

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

$start = 100
$stop = 200
$start..$stop

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
$array[1..$($array.length-1)]

Posted Feb 16 2009, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.