Link to home
Start Free TrialLog in
Avatar of mystikal1000
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.
Avatar of becraig
becraig
Flag of United States of America image

import-module ac* 
Get-ADUser -Filter * | export-csv c:\filename.csv

Open in new window

import-module *activedir*

get-aduser -filter * -SearchBase "DC=mydomain, DC=local" | format-table name,surname | out-file exported.csv
Avatar of mystikal1000
mystikal1000

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
I know, but I want it to read certain AD accounts :)
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Awesome Billprew!!!
You could also do something like ..

gc users.txt | Get-ADUser -Properties * | select GivenName,Initials,Surname,DisplayName,Description,Office,telephoneNumber,mail,HomePage | export-csv data.csv -nti
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


import-module activedirectory
import-csv c:\temp\users.csv | % { Get-ADUser $_.user -properties * | export-csv c:\filename.csv -notype }

Open in new window

Didn't work...
Thanks, glad that was useful.

~bp