Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

Hey, Scripting Guy! How Can I Modify the Email Addresses of All the Users in an OU and Its SubOUs?

 (image) Hey, Scripting Guy! I need to get a list of all the users in an OU and its subOUs, then change their email addresses so those addresses only user lowercase letters. How can I do that?-- TB(image) (image) (image) Hey, TB. You know, we had to think twice before going ahead and answering this question. That’s not because this ...

How Can I Delete All the Users in an Active Directory Group?

(image) Hey, Scripting Guy! How can I delete all the users in an Active Directory group?-- AA(image) (image) (image) Hey, AA. You know, that’s something we Scripting Guys never thought about: a script that could eliminate all the users in a particular group. The only problem we have with that is: where do we start? For example, maybe we ...

How Can I Get a List of All the Users Who Have an Alternate Recipient?

(image) Hey, Scripting Guy! How can I get a list of all the users who have an alternate recipient (altRecipient)?-- SA(image) (image) (image) Hey, SA. You know, one of the great things about being a Scripting Guy is that we don’t ever have to know what we’re talking about; all we do have to know is how to write a script that does ...

How Can I Add a User to a Group if That User Belongs to Two Other Groups?

(image) Hey, Scripting Guy! How can I check to see if a user is in both group A and group B and, if so, add that user to Group C?-- DH(image) (image) (image) Hey, DH. Good heavens, how are we supposed to know that?!? Sheesh. Sorry; we just always wanted to say that. Now that we have that out of our system, here’s a sample script that ...

Hey, Scripting Guy! How Can I Bind to a User Account Using Something Other Than the CN Attribute?

(image) Hey, Scripting Guy! Can I bind to an Active Directory account using the user’s mailNickname or their sAMAccoutName, something other than the CN?-- MB (image) (image) Hey, MB. When you bind to an account in Active Directory, you need to pass GetObject the account’s ADsPath. That means you need to use a line of code similar...