I am using powercli and get-vm to generate a list of VMs and configuration items. I would like to somehow list what folder in vCenter a VM is in, and then sort the VMs by folder, and then by nam...
See more...
I am using powercli and get-vm to generate a list of VMs and configuration items. I would like to somehow list what folder in vCenter a VM is in, and then sort the VMs by folder, and then by name in ascending order. Is this possible? get-vm | Sort Name | % { $vm = Get-View $_.ID $vms = "" | Select-Object VMName, Hostname, IPAddress, OS, TotalCPU, TotalMemory, TotalNics, OverallCpuUsage, MemoryUsage, ToolsStatus, ToolsVersion $vms.VMName = $vm.Name $vms.Hostname = $vm.guest.hostname $vms.IPAddress = $vm.guest.ipAddress $vms.OS = $vm.guest.GuestID $vms.TotalCPU = $vm.summary.config.numcpu $vms.TotalMemory = $vm.summary.config.memorysizemb $vms.TotalNics = $vm.summary.config.numEthernetCards $vms.OverallCpuUsage = $vm.summary.quickStats.OverallCpuUsage $vms.MemoryUsage = $vm.summary.quickStats.guestMemoryUsage $vms.ToolsStatus = $vm.guest.toolsstatus $vms.ToolsVersion = $vm.config.tools.toolsversion $report2 += $vms }