How to get users information using powershell for a certain OU in a domain

How to get users information using powershell for a certain OU in a domain.

Can anyone help please, I'm trying to get some reports about users rights and access levels in a certain OU in a domain.

Thanks for any ones help!!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Will SzymkowskiSenior Solution ArchitectCommented:
Use the below command...
import-module activedirectory
$OU = "ou=test,dc=domain,dc=com"
Get-ADUser -Filter * -SearchBase $OU -Properties * | select | Export-csv "c:\users.csv" -nti

Open in new window

Note: i have used the -Properties * which will provide all of the properties as you did not state which ones you required. It provids better performance if you specify individual properties.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sirichaiphumiratAuthor Commented:
thanks, what would you do when you have a space.

example  $ou = "ou=my test, dc=domain, dc =com"

my current domain setup is....      cb.smbmi.local

my ou im trying to search under is Vendor Support
would my line be   $ou = "ou=vendor support, dc=cb, dc=smbmi, dc=local"    

thanks for helping
Will SzymkowskiSenior Solution ArchitectCommented:
If Vendor Support is the top level OU then the below is correct.

would my line be   $ou = "ou=vendor support, dc=cb, dc=smbmi, dc=local"    

sirichaiphumiratAuthor Commented:
great thank you!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.