AdamUK
Enthusiast
Enthusiast

Apologies for the additional ask, but is there a way I can calculate the total number of VMs per Datacenter/Cluster?  I have amended the script so it reports the total number of VMs in the vCenter instance by adding $total_vms = (Get-VM).count and I also found the command below:

get-cluster | select @{n="cluster";e={$_.name}}, @{n="hosts";e={($_ | get-vmhost).count}}, @{n="vms";e={($_ | get-vm).count}} | sort cluster | ft -auto

which works if I run it manually but if I try to integrate it into the script by assigning it to a variable, the output is as follows:

Microsoft.PowerShell.Commands.Internal.Format.GroupEndData Microsoft.PowerShell.Commands.Internal.Format.FormatEndData

I basically want it to output the results at the beginning of the output file

Reply
0 Kudos