SCVMM Script

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Poshoholic Poshoholic 3 years, 10 months ago.

  • Author
    Posts
  • #7533
    Profile photo of Upinit
    Upinit
    Participant

    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!

  • #7542
    Profile photo of Poshoholic
    Poshoholic
    Member

    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.

You must be logged in to reply to this topic.