Get-Datacenter | Select @{N = 'datcentername'; E = {$_.Name -replace '-','' }}, @{N = 'Cluster_Name'; E = {$datacenter.name}}, @{N = 'VM Count'; E = {( get-vm | where-object { $_.powerstate -eq "poweredOff"}).Count}}
how come this is adding the counts instead of breaking them out per count by Datacenter ?
Human error Im sure ![]()
datacenter1 312
datacenter2 312
datacenter3 312
I need it this formate for nodeExporter
Because you do a Get-VM without a Location parameter, that will return all the VMs.
Use
@{N = 'VM Count'; E = {( Get-VM -Location $_ | where-object { $_.powerstate -eq "poweredOff"}).Count}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Because you do a Get-VM without a Location parameter, that will return all the VMs.
Use
@{N = 'VM Count'; E = {( Get-VM -Location $_ | where-object { $_.powerstate -eq "poweredOff"}).Count}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thank you sir I tried the location but I see was doing it wrong and leaving off $_
ignore sorry cant delete
