Removing the First Item from an Array in PowerShell
This is a quickie, but I often find myself working with arrays of objects when I'm working on a PowerShell script. Occasionally, I need to remove the first item from that array, which I've always done by using the array index: $array = $array[1..($array.count - 1)] . That certainly works, but it's also kindof ugly. Today, I learned a better way! PowerShell does a neat trick with commas, the equals sign, and arrays. If you're assigning an array to a comma delimited list of variables, the array automatically gets split between those variables. I've used that in the past in situations like this: $IPAddress = "192.168.0.1" $First,$Second,$Third,$Fourth=$IPAddress.split(".") And, as you'd expect, that will split the IP Address into octets, with each one going into its named variable. That's great, but what happens if you've got this situation? $IPAddress = "192.168.0.1" $First,$Second=$IPAddress.split("....