{"id":4748,"date":"2012-10-30T11:59:00","date_gmt":"2012-10-30T11:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2012\/10\/30\/powertip-use-a-single-line-powershell-command-to-list-all-users-in-an-ou\/"},"modified":"2012-10-30T11:59:00","modified_gmt":"2012-10-30T11:59:00","slug":"powertip-use-a-single-line-powershell-command-to-list-all-users-in-an-ou","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-use-a-single-line-powershell-command-to-list-all-users-in-an-ou\/","title":{"rendered":"PowerTip: Use a Single Line PowerShell Command to List All Users in an OU"},"content":{"rendered":"<p><b>Summary<\/b>: Use a single line Windows PowerShell command to list all users in an OU.<\/p>\n<p><strong><img decoding=\"async\" alt=\"Hey, Scripting Guy! Question\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" \/>&nbsp;<\/strong>How can I list all users in a particular organizational unit (OU)?<\/p>\n<p>&nbsp; &nbsp; &nbsp;&nbsp;<img decoding=\"async\" alt=\"Hey, Scripting Guy! Answer\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" \/>&nbsp;Use the&nbsp;<b>Get-ADUser<\/b>&nbsp;cmdlet from the ActiveDirectory Module (available from the RSAT tools). Specify the <strong>SearchBase&nbsp;<\/strong>as the name of the OU, and use a wildcard pattern for the&nbsp;<strong>Filter<\/strong><i>.<\/i><\/p>\n<p><i><\/i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Get-ADUser -Filter * -SearchBase &#8220;ou=testou,dc=iammred,dc=net&#8221;<\/p>\n<p><b><span class=\"Apple-tab-span\"> <\/span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Note<\/b>&nbsp;In Windows PowerShell&nbsp;3.0, you do not have to load a module prior to using it.<\/p>\n<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\" border=\"0\" alt=\"\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Use a single line Windows PowerShell command to list all users in an OU. &nbsp;How can I list all users in a particular organizational unit (OU)? &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;Use the&nbsp;Get-ADUser&nbsp;cmdlet from the ActiveDirectory Module (available from the RSAT tools). Specify the SearchBase&nbsp;as the name of the OU, and use a wildcard pattern for the&nbsp;Filter. [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[356,3,45],"class_list":["post-4748","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-powertip","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Use a single line Windows PowerShell command to list all users in an OU. &nbsp;How can I list all users in a particular organizational unit (OU)? &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;Use the&nbsp;Get-ADUser&nbsp;cmdlet from the ActiveDirectory Module (available from the RSAT tools). Specify the SearchBase&nbsp;as the name of the OU, and use a wildcard pattern for the&nbsp;Filter. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4748","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=4748"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4748\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=4748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=4748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=4748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}