PowerShell: Find All Groups Containing A Specific String

PowerShell: Find all groups containing a specific string

Written by

Aleksander Nordgarden-Rødner

in

PowerShell

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 groups that satisfy our needs. Using asterisks as wildcards, we can specify whether the string should be at the start, middle, or end:

Get-ADGroup -Filter "Name -like 'Beginning*'" Get-ADGroup -Filter "Name -like '*Middle*'" Get-ADGroup -Filter "Name -like '*End'"

If we add a pipe and “select” followed by the name of a property outputs results that satisfy the filter, showing the specified property only. It might look something like this:

PS C:\Users\USER> Get-ADGroup -Filter "Name -like 'adm*'" | select name name ---- administrators admins administrative_users

The same method can be applied to the Get-ADUser query, to find users whose name satisfy the Filter criteria.

filterget-adgroupget-adgroupmemberget-aduserPowerShell Outlook: Mark deleted messages as read Do you 10Q?

Comments

By posting a comment, you consent to our collecting the information you enter. See privacy policy for more information.Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More posts

  • Describing a problem is half the battle

    14/08/2023
  • Verify what RSAT features are installed

    07/08/2023
  • State of the Blog 2023

    26/06/2023
  • Installing ADUC from PowerShell

    19/06/2023

Tag » Active Directory Search Group Name Contains