SCVMM Script

Welcome Forums General PowerShell Q&A SCVMM Script

This topic contains 1 reply, has 2 voices, and was last updated by

5 years, 7 months ago.

  • Author
  • #7533

    Points: 0
    Rank: Member

    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?


  • #7542

    Points: 1
    Rank: 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.

The topic ‘SCVMM Script’ is closed to new replies.