Spread the love

I recently had a request to disable a list of users in AD and remove their accounts but I was provided with an excel sheet full of email addresses.

Found a script that will scan a .txt file and reference AD to find the corresponding user account and it spits out a list :).

You can pipe this into a .csv but this script was fit for my purposes.

$users = get-content c:\temp\listofemailaddress.txt

foreach ($user in $users) {  get-aduser -filter {emailaddress -like $user} | select samaccountname}