How to Get Array Length in PowerShell (Count vs Length)
To get the PowerShell array length, read the array’s .Count or .Length property. Both return the number of items, so $cities.Count gives 5 for a five-city array: The tricky part is what happens when a command returns one item, no items, or a collection that isn’t a plain array. I ran every case below in … Read more