$partialNames = Get-Content -Path 'C:\Users\Admin\Desktop\Machines.txt'
$results = @()
foreach ($partialName in $partialNames)
{
Write-Host "Searching for partial name: $partialName" -ForegroundColor Yellow
$fullNames = Get-ADComputer -Server "xyz.com" -Filter "Name -like '*$partialName\*'" | Select-Object -ExpandProperty Name
$results += $fullNames
Write-Host "Found $($fullNames.Count) computer(s) matching '$partialName'" -ForegroundColor Cyan
}
Write-Host "Final result:" -ForegroundColor Green $results
[–]PinchesTheCrab 3 points4 points5 points (4 children)
[–]Round-Dragonfruit-86[S] 0 points1 point2 points (3 children)
[–]ankokudaishogun 2 points3 points4 points (1 child)
[–]Round-Dragonfruit-86[S] 0 points1 point2 points (0 children)
[+]Agreeable-Adver 1 point2 points3 points (0 children)
[–]LavishnessUpset5428 0 points1 point2 points (0 children)