I’m having a PowerCLI issue that I’m not sure how to approach. I have a script, during which, I’m counting different things, e.g.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | $cluster1 = Get-Cluster "Cluster1" $cluster2 = Get-Cluster "Cluster2" #Cluster1 $Cluster1PoweredOnWinVMs = $cluster1 | Get-VM | where {$_.powerstate -eq "PoweredOn"} | Get-VMGuest | where {$_.OSFullName -match "Microsoft"} $NumCluster1PoweredOnWinVMs = $Cluster1PoweredOnWinVMs.count $Cluster1PoweredOnRHELVMs = $cluster1 | Get-VM | where {$_.powerstate -eq "PoweredOn"} | Get-VMGuest | where {$_.OSFullName -match "Red Hat"} $NumCluster1PoweredOnRHELVMs = $Cluster1PoweredOnRHELVMs.count #Cluster2 $Cluster2PoweredOnWinVMs = $cluster2 | Get-VM | where {$_.powerstate -eq "PoweredOn"} | Get-VMGuest | where {$_.OSFullName -match "Microsoft"} $NumCluster2PoweredOnWinVMs = $Cluster2PoweredOnWinVMs.count $Cluster2PoweredOnRHELVMs = $cluster2 | Get-VM | where {$_.powerstate -eq "PoweredOn"} | Get-VMGuest | where {$_.OSFullName -match "Red Hat"} $NumCluster2PoweredOnRHELVMs = $Cluster2PoweredOnRHELVMs.count |
…and so on, for several clusters
Now, I want to take $NumCluster1PoweredOnWinVMs, $NumCluster1PoweredOnRHELVMs, $NumCluster2PoweredOnWinVMs, and $NumCluster2PoweredOnRHELVMs and output them to a CSV, with $cluster1 and $cluster2 in a preceding column.
Help pls.





0 Comments.