Twhite0909
asked on
Powershell script or cmd to search All Active User accounts in AD
I need a script or simple command to search ONLY user accounts and export it to a CSV. I have run other scripts but they grab Service accounts, shared mailboxes, Resources, disabled accounts etc.. I just want Active Users within AD. Any ideas?
Thanks
Thanks
If your user accounts are separated from your mgmt. accounts in different OU's you can use the -searchbase switch to tell Get-ADUser where to search for your users. (Change the distinguishedName to your domain info). Then pipe it out to a csv.
Get-ADUser -Filter {Enabled -eq $True} -searchbase "OU=Users,OU=production,DC =contoso,D C=com" | Export-CSV \\server\share\enabledUser s.csv
Get-ADUser -Filter {Enabled -eq $True} -searchbase "OU=Users,OU=production,DC
ASKER
Get-ADUser -Filter {Enabled -eq $True} -searchbase "OU=Users,OU=production,DC =contoso,D C=com" | Export-CSV \\server\share\enabledUser s.csv
that worked great. Now theyre asking if I can add creation date, department? Do you the syntax for those to add to this cmd?
that worked great. Now theyre asking if I can add creation date, department? Do you the syntax for those to add to this cmd?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Can I combine this with the other script to run.together?
The above is the complete script, as far as we know it.
ASKER
But won't that just give me all all users again and not go to specific OU? that's what I need and that's what the first command I got did it went to a specific oh you called locations where I have all of my office is this week just user accounts anything else. jared mailbox or service accounts things and I don't need to if I could put this - filter properties in with the original command somehow I can pull just use your accounts as well as their
ASKER
Whats the full cmd to have AD search an OU and get the Users as well as creation date?
But I guess it is safe to assume enabled accounts with a given name are real users:
Open in new window