mystikal1000
asked on
Script to query user accounts in AD
I need a script that will read a list of user accounts in a txt file and it will export all of the users information from the AD account (general tab) into a file per line for each account. Prefer a csv file.
import-module *activedir*
get-aduser -filter * -SearchBase "DC=mydomain, DC=local" | format-table name,surname | out-file exported.csv
get-aduser -filter * -SearchBase "DC=mydomain, DC=local" | format-table name,surname | out-file exported.csv
ASKER
Where does it read a list of user accounts from these powershell commands??
Get-aduser looks fit for active directory users.
Filter * says all users
Filter * says all users
ASKER
I know, but I want it to read certain AD accounts :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awesome Billprew!!!
You could also do something like ..
gc users.txt | Get-ADUser -Properties * | select GivenName,Initials,Surname ,DisplayNa me,Descrip tion,Offic e,telephon eNumber,ma il,HomePag e | export-csv data.csv -nti
gc users.txt | Get-ADUser -Properties * | select GivenName,Initials,Surname
Hi,
Please use the below powershell script
You need to provide the input as users.csv
Header should be User example below (samid )
User
ravia
premk
shyamk
Please use the below powershell script
You need to provide the input as users.csv
Header should be User example below (samid )
User
ravia
premk
shyamk
import-module activedirectory
import-csv c:\temp\users.csv | % { Get-ADUser $_.user -properties * | export-csv c:\filename.csv -notype }
ASKER
Didn't work...
Thanks, glad that was useful.
~bp
~bp
Open in new window