Quantcast
Channel: Virtual Machine Manager – General forum
Viewing all articles
Browse latest Browse all 728

Script to list Virtual Machines in a Service Instance and the Host on which they reside.

$
0
0

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.



Viewing all articles
Browse latest Browse all 728

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>