This is what I am doing now...figured there has to be a faster way...any ideas?
$datacenters = get-datacenter | Sort-Object | select name
foreach($datacenter in $datacenters){
$datacentername = get-datacenter -name $datacenter.name | sort-object
$allvms = get-datacenter $datacentername | get-vm
Write-host "Os Full Name Counts: $datacentername"
Write-host ""
$allvms | Get-View | Select @{Name="OS";Expression={ $_.Summary.Config.GuestFullName }} | Group OS | Sort Name | Select Name,@{Name="Total VMs";Expression={ $_.Count }}
}
Try something like this
Get-View -ViewType Datacenter -Property Name -PipelineVariable dc |
ForEach-Object -Process {
Get-View -ViewType VirtualMachine -SearchRoot $dc.MoRef -Property Summary.Config.GuestFullName |
Group-Object {$_.Summary.Config.GuestFullName} |
Sort-Object -Property Name |
Select @{N='DC';E={$dc.Name}},Name,@{Name="Total VMs";Expression={ $_.Count }}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
Get-View -ViewType Datacenter -Property Name -PipelineVariable dc |
ForEach-Object -Process {
Get-View -ViewType VirtualMachine -SearchRoot $dc.MoRef -Property Summary.Config.GuestFullName |
Group-Object {$_.Summary.Config.GuestFullName} |
Sort-Object -Property Name |
Select @{N='DC';E={$dc.Name}},Name,@{Name="Total VMs";Expression={ $_.Count }}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc, thank you as always, so much quicker and more detailed!