Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

find accounts that are not there?

$
0
0

$users=Get-Content"C:\Temp\D2.txt"
foreach ($userin$users) {

$sam=Get-ADUser-ldapfilter"(displayname=$user)"-Property samaccountname | Select-Object-Property samaccountname
$sam
}

the above code works perfect.   It reads the file D2.txt which has 1,514 names inside.  In this format:  LName, FName.   The issue I now have is my code above returns 1,475 samAccountNames with no errors.  How do I pipe to a file all of the accounts it could not find or that were bad?

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles