Get-AdUser: Get all the info of the active directory users using NTID or Email address

If you want to fetch the list of all user data by using there email address, then checkout this powershell script. Get-Aduser is very important powershell command of Microsoft to pull user data
Written by Paayi Tech |01-Aug-2020 | 0 Comments | 207 Views

If you want to export information of the active directory user from PowerShell then check the script below. To run this script you need to do a few tasks. To fetch the information we are using the command called get-aduser. 

If you want to fetch information of the single-user then use this command.

Get-Aduser User_Name


You can select the specific object what you want to retrieve for that particular user, check the example below

Get-Aduser User_Name | Select-Object FirstName, LastName, DisplayName, EmailAddress



If you want to fetch the information for lots of users by using there NTID's or their email address then write all the NTID's inside a notepad and use that notepad to fetch the data as shown below in the script. For this script, we used NTID's or you can say SamAccountName. To run this script open PowerShell as an administrator and run the script.


Get-aduser bulk user export script

If you want to copy the script then pick it from here and modify changes accordingly. 

Get-Content C:Users-Downloads-NTIDs.txt | ForEach-Object { 
Get-ADUser -Filter {SamAccountName -eq $_} -Properties DistinguishedName,Name,SamAccountName,DisplayName,EmailAddress,LastLogonDate,Enabled | Select-Object DistinguishedName,
SamAccountName,DisplayName,EmailAddress,LastLogonDate | Export-CSV C:Users-Downloads-users.csv -Append 


Please use backlash, our editor is giving problem when ever we write backlash. so we used "-" over here C:Users-Downloads-NTIDs.txt




Login/Sign Up


Related Posts

© Copyright 2020, All Rights Reserved.

This site uses cookies. By continuing to use this site or clicking "I Agree", you agree to the use of cookies. Read our cookies policy and privacy statement for more information.