Script to list Virtual Machines in a Service Instance and the Host location

Forum: SCVMM
Viewing 1 post (of 1 total)
  • #228672
    Profile photo of Richard Stevenson
    Richard Stevenson
    Participant

    I am trying to write a script which will list all the virtual machines that comprise a service instance and detail on which Hyper-V host each virtual machine is currently located.

    I have managed to list the VMs for a specific service instance with the script below:

    PS C:\Windows\system32> $Service = Get-SCService -Name “POC2 BI4 Edge”

    $ComputerTier = Get-SCComputerTier -Service $Service

    $VMs = Get-SCComputerTier -Service $Service | Select-Object -property vms

    $VMs

     

    VMs

    {ms-svr1766.msmas.co.uk}

    {ms-svr1767.msmas.co.uk}

    {ms-svr1765.msmas.co.uk}

    The next step is to take to the VMs listed and pass them into the “Get-VM” command before returning the host value for each virtual machine.  One of the issues may be that the server names listed below are contained in parenthesis.

    If anyone could help with this I would be most grateful.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.