{"id":5400,"date":"2020-02-17T17:00:00","date_gmt":"2020-02-17T16:00:00","guid":{"rendered":"https:\/\/www.razumny.no\/?p=5400"},"modified":"2020-02-17T11:37:00","modified_gmt":"2020-02-17T10:37:00","slug":"powershell-find-all-enabled-user-accounts","status":"publish","type":"post","link":"https:\/\/www.razumny.no\/?p=5400","title":{"rendered":"PowerShell: Find all enabled user accounts"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Some time ago, I was asked to provide a list of all enabled user accounts in Active Directory.  My thoughts immediately went to PowerShell, assuming that there would be tools available to achieve that task. I knew that the <code>Get-ADUser<\/code> query, combined with a parameter, would likely be the ticket.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using the <code>-ldapfilter<\/code> parameter to only return results that had a useraccountcontrol value of 512, I omitted the other values, and opted to send the results to a text file. As per <a href=\"https:\/\/support.microsoft.com\/en-us\/help\/305144\/how-to-use-useraccountcontrol-to-manipulate-user-account-properties\">this article<\/a>, useraccountcontrol values are cumulative, meaning that a value of512 means a &#8220;normal&#8221; user account, which is not disabled.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">My query looked like this:  <code>get-aduser -ldapfilter \"(useraccountcontrol=512)))\"<\/code>, and returned the results we wanted.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some time ago, I was asked to provide a list of all enabled user accounts in Active Directory. My thoughts immediately went to PowerShell, assuming that there would be tools available to achieve that task. I knew that the Get-ADUser query, combined with a parameter, would likely be the ticket. Using the -ldapfilter parameter to [&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,1076,1218,1217],"class_list":["post-5400","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-get-aduser","tag-ldapfilter","tag-parameter","tag-useraccountcontrol"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p2ukSU-1p6","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":7070,"url":"https:\/\/www.razumny.no\/?p=7070","url_meta":{"origin":5400,"position":0},"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":[]},{"id":5451,"url":"https:\/\/www.razumny.no\/?p=5451","url_meta":{"origin":5400,"position":1},"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":5402,"url":"https:\/\/www.razumny.no\/?p=5402","url_meta":{"origin":5400,"position":2},"title":"PowerShell: Count enabled user accounts","author":"Aleksander Nordgarden-R\u00f8dner","date":"16\/03\/2020","format":false,"excerpt":"A few weeks ago, I showed you how to get a list of all enabled user accounts in PowerShell. Perhaps unsurprisingly, after having presented this to my customer, it transpired that what they really wanted, was to know how many enabled user accounts existed in Active Directory. Once more, my\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":5400,"position":3},"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":5404,"url":"https:\/\/www.razumny.no\/?p=5404","url_meta":{"origin":5400,"position":4},"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":5626,"url":"https:\/\/www.razumny.no\/?p=5626","url_meta":{"origin":5400,"position":5},"title":"PowerShell: Find all groups containing a specific string","author":"Aleksander Nordgarden-R\u00f8dner","date":"07\/09\/2020","format":false,"excerpt":"Sometimes, you need a list of all groups whose name contain a specific string, whether that is in the beginning, middle, or end of the group name. As we've seen previously, looking up groups in PowerShell is done with the Get-ADGroup command. Adding the -filter parameter allows us to find\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\/5400","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=5400"}],"version-history":[{"count":3,"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/posts\/5400\/revisions"}],"predecessor-version":[{"id":5409,"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/posts\/5400\/revisions\/5409"}],"wp:attachment":[{"href":"https:\/\/www.razumny.no\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.razumny.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.razumny.no\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}