I have a script that will give me the total count of Powered on VMs in each environment, but I would love for it to automatically add the values together and display an overall total, instead of ...
See more...
I have a script that will give me the total count of Powered on VMs in each environment, but I would love for it to automatically add the values together and display an overall total, instead of exporting each vCenter's count to a CSV. For example, I'd like it to see total VC01=100, VC02=200, VC03=50, VC04=250, VC05=100. Total = 700 Powered On VMs. Anyone have any suggestions? ------------------------ # Build array for each vCenter with vDS switch $array = "vc01", "vc0e", "vc0e", "vc04", "vc05" for($count=0;$count -lt $array.length; $count++) { # Connect to All vCenter Servers, one at a time. connect-viserver $array[$count] # Get VM counts & export to CSV Get-VMHost | Get-VM | where-object {$_.PowerState -eq "PoweredOn"}| Measure-Object | export-csv -notypeinformation c:\ben\vmware\$($array[$count])_vm_count.csv # Disconnect from vCenter Servers disconnect-viserver -confirm:$false } ------------------------ Thanks in advance!