SCVMM Script

Looking for some assistance on a simple SCVMM script. What I need is to get a list of all virtual machines on a particular VM Host but the script has to get this information from the SCVMM server.

Currently I can use the following and get all the virtual machines for all VM hosts on the SCVMM server:

Add-PSSnapin Microsoft.SystemCenter.VirtualMachineManager
Get-VM -VMMServer SCVMMServer | Sort-Object Hostname | Select-Object HostName, Name, ComputerName, Status, StopAction, StartAction

However, how can I parse this information to grab only the virtual machines from a particular VM host rather than all of them?

Thanks!

Something like this:

$vm = Get-VM -VMMServer SCVMMServer -Name MyVMName
Get-VM -VMMServer SCVMMServer | Where-Object {$_.VMHost.Name -eq $vm.VMHost.Name}

This may also work (I don’t have the SCVMM cmdlets in front of me right now, that’s on my todo list):

Get-VMHost -Name MyVMHostName | Get-VM

That last one really depends on how the cmdlets are designed.