Hyper-V: Search for Guest VMs Utilizing Certain Storage Paths

$pathSearch='C:\ClusterShare\RandomFolder'

$pathSearch='C:\ProgramData'
$allHyperVHosts={(Get-ClusterNode | Where { $_.State –eq "Up" }).Name | %{$_.ToLower()}}.Invoke() 
$allVms=foreach ($hyperVHost in $allHyperVHosts){invoke-command -computername $hyperVHost -scriptblock{Get-VM |select Name,Path}}
$allVms|?{$_.Path -like "*$pathSearch*"}

Leave a Reply

Your email address will not be published. Required fields are marked *