I've built the following User search based on first name and last name for AD. The way it's written, it only returns the first result. How can I re-write this to return all the results?
Write-Host "Please enter a first name to search: " -NoNewline -ForegroundColor Yellow $first = Read-Host Write-Host "Please enter a last name to search: " -NoNewline -ForegroundColor Yellow $last = Read-Host $fullname = $first + "*" + $last + "*" $username = get-aduser -filter{displayname -like $fullname} -properties * | select -expand samaccountname if ((get-aduser -filter{displayname -like $fullname}) -ne $null) { $fname = get-aduser -identity $username -pr * | select -ExpandProperty givenname $lname = get-aduser -identity $username -pr * | select -ExpandProperty surname $office = get-aduser -identity $username -pr * | select -ExpandProperty office $description = get-aduser -identity $username -pr * | select -ExpandProperty description $notes = get-aduser $username -properties info | Select-Object -ExpandProperty info $enabled = get-aduser $username -pr * | select -ExpandProperty enabled Write-Host "First Name: " -NoNewline -ForegroundColor Green Write-Host $fname -ForegroundColor Gray Write-Host "Last Name: " -NoNewline -ForegroundColor Green Write-Host $lname -ForegroundColor Gray Write-Host "Username: " -NoNewline -ForegroundColor Green Write-Host $username -ForegroundColor Gray Write-Host "Account Enabled: " -NoNewline -ForegroundColor Green Write-Host $enabled -ForegroundColor Gray Write-Host "Location: " -NoNewline -ForegroundColor Green Write-Host $office -ForegroundColor Gray Write-Host "Account Description: " -NoNewline -ForegroundColor Green Write-Host $description -ForegroundColor Gray Write-Host "Account Notes: " -ForegroundColor Green Write-Host $notes -ForegroundColor Gray } else { Write-Host "User $fullname does not exist in AD." -ForegroundColor Red }