Quantcast
Channel: Windows Server – Yusuf Ozturk
Viewing all articles
Browse latest Browse all 127

Search VM in Hyper-V Hosts via PowerShell

$
0
0
You can search a VM name in your Hyper-V host list like this: $VMName = "Server Name" $Servers = Get-Content C:\servers.txt foreach ($Server in $Servers) { $VMs = Get-WMIObject -Class Msvm_ComputerSystem -Namespace "root\virtualization" -ComputerName $Server foreach ($VM in $VMs) { if ($VM.ElementName -eq $VMName) { Write-Host $Server } } } It uses WMI so both [...]

Viewing all articles
Browse latest Browse all 127

Trending Articles