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.
If anyone could help with this I would be most grateful.