{"id":5626,"date":"2020-09-07T17:00:22","date_gmt":"2020-09-07T15:00:22","guid":{"rendered":"https:\/\/www.razumny.no\/?p=5626"},"modified":"2020-08-20T15:06:01","modified_gmt":"2020-08-20T13:06:01","slug":"powershell-find-all-groups-containing-a-specific-string","status":"publish","type":"post","link":"https:\/\/www.razumny.no\/?p=5626","title":{"rendered":"PowerShell: Find all groups containing a specific string"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">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&#8217;ve seen previously, looking up groups in PowerShell is done with the Get-ADGroup command. Adding the -filter parameter allows us to find groups that satisfy our needs. Using asterisks as wildcards, we can specify whether the string should be at the start, middle, or end:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-ADGroup -Filter \"Name -like 'Beginning*'\"\nGet-ADGroup -Filter \"Name -like '*Middle*'\"\nGet-ADGroup -Filter \"Name -like '*End'\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If we add a pipe and &#8220;select&#8221; followed by the name of a property outputs results that satisfy the filter, showing the specified property only. It might look something like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS C:\\Users\\USER> Get-ADGroup -Filter \"Name -like 'adm*'\" | select name\n\r\nname                \r\n----   \nadministrators\nadmins\nadministrative_users<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The same method can be applied to the Get-ADUser query, to find users whose name satisfy the Filter criteria.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;ve seen previously, looking up groups in PowerShell is done with the Get-ADGroup command. Adding the -filter parameter allows us to find groups that satisfy our needs. [&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":[1271,1189,1186,1187,969],"class_list":["post-5626","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-filter","tag-get-adgroup","tag-get-adgroupmember","tag-get-aduser","tag-powershell"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p2ukSU-1sK","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":7467,"url":"https:\/\/www.razumny.no\/?p=7467","url_meta":{"origin":5626,"position":0},"title":"PowerShell: Listing Managed by User for groups","author":"Aleksander Nordgarden-R\u00f8dner","date":"08\/09\/2026","format":false,"excerpt":"One of my customers have a set of access groups set up for access to network shares. These all list a user in the Managed By field, because said user is the one who can approve or deny requests for access to these shares. I needed to get a list\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":5270,"url":"https:\/\/www.razumny.no\/?p=5270","url_meta":{"origin":5626,"position":1},"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":6303,"url":"https:\/\/www.razumny.no\/?p=6303","url_meta":{"origin":5626,"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":7002,"url":"https:\/\/www.razumny.no\/?p=7002","url_meta":{"origin":5626,"position":3},"title":"PowerShell: Default properties","author":"Aleksander Nordgarden-R\u00f8dner","date":"19\/12\/2022","format":false,"excerpt":"Last week, when describing how to return specific properties, I mentioned that the command returns some standard properties, which is why I didn't have to specify that it should get the Displayname for the members of the group. What properties are by default returned for the commonly used commands? Get-ADComputerDistinguishedName,\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":6301,"url":"https:\/\/www.razumny.no\/?p=6301","url_meta":{"origin":5626,"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":6979,"url":"https:\/\/www.razumny.no\/?p=6979","url_meta":{"origin":5626,"position":5},"title":"Powershell: A script to find all members of several groups refined","author":"Aleksander Nordgarden-R\u00f8dner","date":"07\/11\/2022","format":false,"excerpt":"One of the scripts that I use most often is the one I wrote about back in September of 2019. Usually, I only run it for up to ten or so groups, so it's not a big problem to simply swap out the group name, rince and repeat. Recently, however,\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":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/posts\/5626","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=5626"}],"version-history":[{"count":1,"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/posts\/5626\/revisions"}],"predecessor-version":[{"id":5628,"href":"https:\/\/www.razumny.no\/index.php?rest_route=\/wp\/v2\/posts\/5626\/revisions\/5628"}],"wp:attachment":[{"href":"https:\/\/www.razumny.no\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5626"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.razumny.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5626"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.razumny.no\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5626"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}