Get the Parent OU for an AD Object

I have mentioned before that the Charlotte PowerShell User group was frequented by Scripting Guy Ed Wilson, and his wife Teresa. I’m sad to say that they have moved away, but am happy that Brian Wilhite has been running the meetings since.  I mentioned to Brian that I had a cool way to get the parent container of an Active Directory object using ADSI:

Brian’s response was, “why not just use a substring? I came up with this:

The string method is, of course faster. But If the parent object isn’t an OU, try the first method. It always works.

About Alan

This entry was posted in Active Directory, PowerShell, Scripting, Windows Administration and tagged , . Bookmark the permalink.

Leave a Reply