Author: DaisyStevens100

Powercli: Get VM’s With CPU and Memory Reservation

Powercli: Get VM’s With CPU and Memory Reservation

Get-VM | Where-Object {$_.ExtensionData.ResourceConfig.MemoryAllocation.Reservation -ne "0" -or $_.ExtensionData.ResourceConfig.CpuAllocation.Reservation -ne "0"}
Advertisements
PowerCLI: Memory Usage Report Script

PowerCLI: Memory Usage Report Script

The Below one liner will generate a CSV file containing the following

  • VM Host
  • VM Folder
  • VM Name
  • VM Memory Allocation
  • VM Memory Average Usage Last 30 Days
PowerCLI C:\> get-vm | Where {$_.PowerState -eq "PoweredOn"} | sort Name | Select-Object VMHost,Folder,Name,MemoryGB,@{N="Memory Usage (Average Over 30 Days), %" ; E={[Math]::Ro
und((($_ | Get-Stat -Stat mem.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} | Format-Table -autosize -Property VMho
st,Folder,Name,MemoryGB,"Memory Usage (Average Over 30 Days), %" | Export-Csv C:\temp\MemoryUsage.CSV