List of each of your vms:

Get-VM | Where {$_.PowerState -eq "PoweredOn"} | 
Select Name, Host, NumCpu, MemoryMB, <code>
 @{N=&quot;Cpu.UsageMhz.Average&quot;;E={[Math]::Round((($_ |Get-Stat -Stat cpu.usagemhz.average -Start (Get-Date).AddHours(-24)-IntervalMins 5 -MaxSamples (12) |Measure-Object Value -Average).Average),2)}}, </code>
 @{N=&quot;Mem.Usage.Average&quot;;E={[Math]::Round((($_ |Get-Stat -Stat mem.usage.average -Start (Get-Date).AddHours(-24)-IntervalMins 5 -MaxSamples (12) |Measure-Object Value -Average).Average),2)}} `
 | Export-Csv c:\Temp\Temp.csv

VMs per Resource Pool:

Get-ResourcePool | Where {$_.Name -ne “Resources“ }| Select Name, @{N=“NumVM“;E={($_ | Get-VM).Count}} | Sort Name|Export-Csv -NoTypeInformation c:\Temp.csv

 

SVMotion via PowerCLI :

Get-VM “Test“ |Move-VM -datastore (Get-datastore “MyDatastore“)

 

The Move-VM Cmdlet covers a multiple of sins, lets check some out, you want VMotion:

Get-VM -Name “Test“ |Move-VM -Destination (Get-VMHost MyHost)

 

Moving a VM to a new folder:

Move-VM -VM (Get-VM -Name MyVM)-Destination (Get-Folder -Name Production)

 

Moving a VM to a new resource pool:

Move-VM -VM (Get-VM -Name MyVM)-Destination (Get-ResourcePool -Name “Important“)

VM guest Disk size:



ForEach ($VM in Get-VM ){($VM.Extensiondata.Guest.Disk | Select @{N="Name";E={$VM.Name}},DiskPath, @{N="Capacity(MB)";E={[math]::Round($_.Capacity/ 1MB)}}, @{N="Free Space(MB)";E={[math]::Round($_.FreeSpace / 1MB)}}, @{N="Free Space %";E={[math]::Round(((100* ($_.FreeSpace))/ ($_.Capacity)),0)}})}


Podcast also available on PocketCasts, SoundCloud, Spotify, Google Podcasts, Apple Podcasts, and RSS.

One response

Leave a comment

The Podcast

Join Naomi Ellis as she dives into the extraordinary lives that shaped history. Her warmth and insight turn complex biographies into relatable stories that inspire and educate.

About the podcast