{"id":6301,"date":"2021-02-22T17:00:00","date_gmt":"2021-02-22T16:00:00","guid":{"rendered":"https:\/\/www.razumny.no\/?p=6301"},"modified":"2021-02-09T13:05:01","modified_gmt":"2021-02-09T12:05:01","slug":"finding-the-full-ou-path-of-an-ad-ou","status":"publish","type":"post","link":"https:\/\/www.razumny.no\/?p=6301","title":{"rendered":"Finding the full OU path of an AD OU"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Using PowerShell, I was building a script to identify a subset of the groups in a given organizational unit (OU). As you may know, these are built up of subsections with the prefixes CN (common name) and DC (Domain Component). In order to have the script run successfully, you need to specify the OU using the full path, which looks something like this: <code>CN=Users,DC=Fabrikam,DC=com<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The easiest and quickest way I know of finding this path, is by searching for one of the members (be it user or group) using PowerShell:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">When searching for a user:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>Get-ADUser ChewDavid<\/code><br><code>DistinguishedName : CN=Chew David,OU=NorthAmerica,OU=Sales,OU=UserAccounts,DC=FABRIKAM,DC=COM<br>Enabled : True<br>GivenName : David<br>Name : Chew David<br>ObjectClass : user<br>ObjectGUID : e1418d64-096c-4cb0-b903-ebb66562d99d<br>SamAccountName : ChewDavid<br>SID : S-1-5-21-2889043008-4136710315-2444824263-3544<br>Surname : David<br>UserPrincipalName : <\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">When searching for a group:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>Get-ADGroup -Identity Administrators<br>DistinguishedName : CN=Administrators,CN=Builtin,DC=Fabrikam,DC=com<br>GroupCategory : Security<br>GroupScope : DomainLocal<br>Name : Administrators<br>ObjectClass : group<br>ObjectGUID : 02ce3874-dd86-41ba-bddc-013f34019978<br>SamAccountName : Administrators<br>SID : S-1-5-32-544<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In both cases, we can then read the OU out of the results. For the user in this example, it is <code>OU=NorthAmerica,OU=Sales,OU=UserAccounts,DC=FABRIKAM,DC=COM<\/code>, whereas it is <code>CN=Builtin,DC=Fabrikam,DC=com<\/code> for the group.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using PowerShell, I was building a script to identify a subset of the groups in a given organizational unit (OU). As you may know, these are built up of subsections with the prefixes CN (common name) and DC (Domain Component). In order to have the script run successfully, you need to specify the OU using [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[615],"tags":[760,1347,1348,1346,1349,969],"class_list":["post-6301","post","type-post","status-publish","format-standard","hentry","category-how-to-2","tag-active-directory","tag-cn","tag-common-name","tag-dc","tag-organizational-unit","tag-powershell"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p2ukSU-1DD","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":5451,"url":"https:\/\/www.razumny.no\/?p=5451","url_meta":{"origin":6301,"position":0},"title":"PowerShell: Pipe output to CSV file","author":"Aleksander Nordgarden-R\u00f8dner","date":"11\/05\/2020","format":false,"excerpt":"Last week, I showed you how to get specific properties for all users in a given OU. Knowing that the output of that query quickly gets hard to navigate, wanting to remove the extraneous data that the customer didn't request, and assuming that they wanted to manipulate the data, I\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/www.razumny.no\/?cat=820"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5450,"url":"https:\/\/www.razumny.no\/?p=5450","url_meta":{"origin":6301,"position":1},"title":"PowerShell: Getting properties for all user objects in a given OU","author":"Aleksander Nordgarden-R\u00f8dner","date":"04\/05\/2020","format":false,"excerpt":"Two weeks ago, I showed you how I got some specific properties for a specific user. Perhaps unsurprisingly, the next request from my customer was a similar dump from a specific OU. While the Identity parameter works well when you're dealing with a specific user, it doesn't help when you\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/www.razumny.no\/?cat=820"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":6303,"url":"https:\/\/www.razumny.no\/?p=6303","url_meta":{"origin":6301,"position":2},"title":"Finding all groups without a manager in a specific OU in AD","author":"Aleksander Nordgarden-R\u00f8dner","date":"01\/03\/2021","format":false,"excerpt":"Last week, I showed you how you can easily find the OU to use when looking for the members of a specific OU. Today, I'd like to show you how I use that information. The background was that we use AD groups to control access to network shares. In order\u2026","rel":"","context":"In &quot;How To&quot;","block_context":{"text":"How To","link":"https:\/\/www.razumny.no\/?cat=615"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.razumny.no\/wp-content\/uploads\/image-47.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":5265,"url":"https:\/\/www.razumny.no\/?p=5265","url_meta":{"origin":6301,"position":3},"title":"Building a script to find all members of a given group","author":"Aleksander Nordgarden-R\u00f8dner","date":"09\/09\/2019","format":false,"excerpt":"Some time ago, I was asked to provide a list of everyone with access to a specific system. After communicating with the client, it transpired that they were particularly interested in knowing who were the members of a set of Active Directory groups. While this can be done manually, I\u2026","rel":"","context":"In &quot;How To&quot;","block_context":{"text":"How To","link":"https:\/\/www.razumny.no\/?cat=615"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5270,"url":"https:\/\/www.razumny.no\/?p=5270","url_meta":{"origin":6301,"position":4},"title":"PowerShell: Building a script to find all members of several given groups","author":"Aleksander Nordgarden-R\u00f8dner","date":"16\/09\/2019","format":false,"excerpt":"Last week, I showed you how I find all the nested members of a specified group. When we get requests for such audits, however, they usually specify doing so for a number of groups. Now, we could of course do it, one group at a time, adding information to our\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/www.razumny.no\/?cat=820"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5404,"url":"https:\/\/www.razumny.no\/?p=5404","url_meta":{"origin":6301,"position":5},"title":"PowerShell: Find all users in a specific OU","author":"Aleksander Nordgarden-R\u00f8dner","date":"24\/02\/2020","format":false,"excerpt":"One of my customers asked for an overview of the UPNs of all users in a specific OU. Having become fairly familiar with the Get-ADUser command, I decided to see if I couldn't make it do this, too. I knew that I would need to filter the results of the\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/www.razumny.no\/?cat=820"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/posts\/6301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.razumny.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6301"}],"version-history":[{"count":1,"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/posts\/6301\/revisions"}],"predecessor-version":[{"id":6302,"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/posts\/6301\/revisions\/6302"}],"wp:attachment":[{"href":"https:\/\/www.razumny.no\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.razumny.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.razumny.no\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}