Scripting Blog

A place to learn about PowerShell and share stories of automation

How Do I Bind to a User Account in a Sub-OU?

Hey, Scripting Guy! How do I bind to a user account when the user is in a sub-OU? Code like this doesn’t work: LDAP://CN=Ken Meyer, OU=NA\Human Resources, DC=fabrikam, dc=com.-- RD Hey, RD. The past few days we’ve done some lengthy answers to questions, so we decided to be a little lazy today (hey, it is Friday!) and take an easy one. In ...

How Can I Enumerate All the Objects in an Active Directory OU?

Hey, Scripting Guy! How can I enumerate all the objects in an Active Directory OU?-- RB Hey, RB. By the way, thanks: it’s always nice to get an easy question every once in awhile! Enumerating all the objects in an OU is almost embarrassingly-simple: by default, any time you bind to an OU using ADSI you automatically get back a collection of...

Why Doesn't My Search Return All My User Accounts?

Hey, Scripting Guy! I’m trying to pull a list of all my users out of Active Directory. I’m using ADO to search for these users, but no matter what I do I can only get 1,000 user names, even though we probably have 10 times that many user accounts. What could I be doing wrong?-- MC, Athens, GA Hey, MC. Boy, if we had a nickel for every ...

Can I Get a List of All My User Accounts?

Hey, Scripting Guy! Is there any way to get a list of all the user accounts in Active Directory?-- CB, Fremont, CA Hey, CB. By far the quickest and easiest way to do this is to search Active Directory for all your user accounts. Here’s a sample script that searches the fabrikam.com domain; to search your own domain, just edit the LDAP ...