Link to home
Get AccessLog in
Avatar of Milo Techie
Milo TechieFlag for United States of America

asked on

through Powershell i would like to look up a list of user names (first.lastname) and pull information from Active directory on email address, sam account and display name.

This is what i have so far but its not working. so i am stuck here. any help would be appreciated. Thanks.

Import-Module activedirectory


#Import the unmanaged file.

$csvpath = (import-csv C:\temp\test1.csv).”name”


#Run a loop to go through every email within the unmanaged account, then export accounts that exist on our Active Directory.

$results = Foreach($name in $csvpath) {


                #domain name details

                Get-ADUser -Filter "ANR -eq '$($User.Name)'" -SearchBase "DC=domain,DC=domain,DC=com" -Server ip address –properties DisplayName,sAMAccountName,mail | select DisplayName,sAMAccountName,mail



$results | ft


#Export the results to locations specified.

$results | export-csv C:\temp\test1_results.csv -NoTypeInformation

Avatar of oBdA

Link to home
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access
Avatar of Milo Techie


that is what i needed. Thank you for the assistance!