{"id":5450,"date":"2020-05-04T17:00:00","date_gmt":"2020-05-04T15:00:00","guid":{"rendered":"https:\/\/www.razumny.no\/?p=5450"},"modified":"2021-01-26T18:00:50","modified_gmt":"2021-01-26T17:00:50","slug":"powershell-getting-properties-for-all-user-objects-in-a-given-ou","status":"publish","type":"post","link":"https:\/\/www.razumny.no\/?p=5450","title":{"rendered":"PowerShell: Getting properties for all user objects in a given OU"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.razumny.no\/?p=5446\">Two weeks ago<\/a>, 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&#8217;re dealing with a specific user, it doesn&#8217;t help when you want all users.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Furthermore, they requested an overview showing only users in a specific OU, For this, we need to use the SearchBase parameter, together with a wildcarded Filter parameter, like so: <code>Get-ADUser -Filter * -SearchBase \"OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM\"<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Tacking on the properties we wanted, the final query looks like this:<code>Get-ADUser -Filter * -SearchBase \"OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM\" -properties CN, DisplayName, LastLogonDate, Manager<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The output gets a little chaotic, so I will show you how to get it into CSV format next week.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;re dealing with a specific user, it doesn&#8217;t help when you want all users. Furthermore, they [&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":[820],"tags":[1187,969],"class_list":["post-5450","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-get-aduser","tag-powershell"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p2ukSU-1pU","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":5451,"url":"https:\/\/www.razumny.no\/?p=5451","url_meta":{"origin":5450,"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":5404,"url":"https:\/\/www.razumny.no\/?p=5404","url_meta":{"origin":5450,"position":1},"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":[]},{"id":6303,"url":"https:\/\/www.razumny.no\/?p=6303","url_meta":{"origin":5450,"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":5450,"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":6301,"url":"https:\/\/www.razumny.no\/?p=6301","url_meta":{"origin":5450,"position":4},"title":"Finding the full OU path of an AD OU","author":"Aleksander Nordgarden-R\u00f8dner","date":"22\/02\/2021","format":false,"excerpt":"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\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":7070,"url":"https:\/\/www.razumny.no\/?p=7070","url_meta":{"origin":5450,"position":5},"title":"PowerShell: Find User based on partial name","author":"Aleksander Nordgarden-R\u00f8dner","date":"06\/02\/2023","format":false,"excerpt":"Some time ago, I needed to look up the account names of a handful of users in Active Directory. The information I had beforehand was their names. I did not have ADUC available to me, but I did have PowerShell. This is an excellent use case for the Get-ADUser cmdlet\u2026","rel":"","context":"In &quot;How To&quot;","block_context":{"text":"How To","link":"https:\/\/www.razumny.no\/?cat=615"},"img":{"alt_text":"Get-ADUser : A positional parameter cannot be found that accepts argument 'Firstname Surname'.\nAt line:1 char:1\n+ Get-ADUser -Filter displayName \"Firstname Surname\"\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n    + CategoryInfo          : InvalidArgument: (:) [Get-ADUser], ParameterBindingException\n    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.GetADUser","src":"https:\/\/i0.wp.com\/www.razumny.no\/wp-content\/uploads\/image-114.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.razumny.no\/wp-content\/uploads\/image-114.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.razumny.no\/wp-content\/uploads\/image-114.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.razumny.no\/wp-content\/uploads\/image-114.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/posts\/5450","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=5450"}],"version-history":[{"count":6,"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/posts\/5450\/revisions"}],"predecessor-version":[{"id":6273,"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/posts\/5450\/revisions\/6273"}],"wp:attachment":[{"href":"https:\/\/www.razumny.no\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.razumny.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.razumny.no\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}