Param($parentvhd, $searchpath) if ($PSBoundParameters.Count -ne 2) { Write-Host "Error: .\find-childvhd.ps1 -ParentVhd -SearchPath "; exit } if (!(Test-Path($parentvhd))) { Write-Host "Error: VHD file ($parentvhd) not found."; exit } if (!(Test-Path($searchpath))) { Write-Host "Error: Path ($searchpath) not found."; exit } #$parentvhd = Split-path $parentvhd -Leaf #Get-ChildItem -Path $searchpath -Include "*.*vhd*" -Recurse | Get-VHD|Where {$_.ParentPath -like "*$parentvhd" } |Select Path, ParentPath Get-ChildItem -Path $searchpath -Include "*.*vhd*" -Recurse | Get-VHD|Where {$_.ParentPath -eq "$parentvhd" } |Select Path, ParentPath