param ($ShowAll) write-host "#Gets Resource Limits of VM's. –Showall Parameter can be used to remove filter." $vmset = Get-view -ViewType VirtualMachine if ($ShowAll ){ Write-Host "#Show all VM's" }else{ #filter write-host "#Use ""-ShowAll True "" to show all VM's" $vmset = $vmset | where { ($_.Config.MemoryAllocation.Limit -gt 0) -OR $_.Config.CpuAllocation.Limit -gt 0 } } $table = @() $vmset | % { if ($i -gt 0 ) {$i = 0}else{$i=$i+1} $_ | % { $row = "" | select Name, MemoryLimit, CpuLimit, MemoryMB, MemoryReservation, CpuReservation $row.Name = $_.Name $row.MemoryMB = $_.Summary.Config.MemorySizeMB $row.MemoryReservation = $_.Config.memoryallocation.reservation $row.MemoryLimit = $_.Config.memoryallocation.limit $row.CpuReservation = $_.Config.CpuAllocation.reservation $row.CpuLimit = $_.Config.CpuAllocation.limit $table += $row $i = $i + 1 } } $table |
Output looks like this:
No comments:
Post a Comment