Saturday, November 16, 2019

Get AD object when you know the email address of the object only.

Create a notepad file and copy the email address to a file C:\temp\list1.txt

$list1 = Get-Content C:\temp\list1.txt

foreach($i in $list1){
Get-ADObject -Filter {(mail -like $i)} |
Select-Object name, objectclass,DistinguishedName |
Export-Csv c:\temp\ADObjectList.csv -Append -NoTypeInformation
}