I have a question how to extract correct info from PowerCLI array.
I have the following code that finds and put into $DssCluster all Datastores on the cluster:
$cluster =Get-Cluster-Name$ClusterName $DssCluster = @() $VMHostCluster =Get-VMHost-Location$cluster foreach ($hin$VMHostCluster){ $DSH =Get-Datastore-VMHost$h foreach ($dsin$dsh) { if ($DssCluster-notcontains$ds) { $DssCluster +=$DS } } } I know there are 4 Datastores under my cluster and when I am doing "write$DssCluster" I have correct information. However, when I am counting it: write$DssCluster.Count I have "5" instead of "4". I think it's because it's counting the top line as well. I could ignore the wrong number, but I also have issue when I am trying to extract the info from this information array and use it, looks like it's grabing first line and of course there is no Datastore with name as the first line. Any help would be really apreciated. Thank you