Link to home
Create AccountLog in
Avatar of wlcsd-networkmanager
wlcsd-networkmanagerFlag for United States of America

asked on

Compare static list of usernames against Active Directory

I have a static list of usernames that I want to compare against Active Directory to determine if they exist or not.  The list of names is in text format.  Ideally, I would like to know if the object exists even if the account is disabled.
ASKER CERTIFIED SOLUTION
Avatar of soostibi
soostibi
Flag of Hungary image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of FDiskWizard
This will work on a file of userids (SamAccountName)


Get-content "c:\Script Files\Users.txt" | ForEach-Object {

$user=Get-QADUser $_
If ($user -ne $null)
{Write-Host "$_.SamAccountName User Account Found"}
Else {Write-Host "$_.SamAccountName User Account *NOT* Found"}
}
I don't know how fancy you need that to be... It could be tweaked to export out to a file, etc...
Oops. Just leave the .SamAccountName off of the $_
Avatar of wlcsd-networkmanager

ASKER

Works great.  Thanks for the tip.