Get-ADPrincipalGroupMembership -Identity $ntaccount1 | select Name | Sort Name The above command displays the Names of all the AD groups an active directory account is in. I tried to add -Filter to the end but it does not work. How can I filter out the results to only display things that contain a certain string?
Edit: I tried one solution posted below but I want the output to be just the AD group without any titles or heading. It currently looks like this:
Name ----- group_here 1 Answer
There's no provider filter parameter for Get-ADPrincipalGroupMemebership, so you'll have to use late filtering:
Get-ADPrincipalGroupMembership -Identity $ntaccount1 | select Name | Where-Object {$_.name -like '*certain string*' } | Sort Name Edit - If you just wanted the names:
Get-ADPrincipalGroupMembership -Identity $ntaccount1 | select-ExpandProperty Name | Where-Object { $_ -like '*certain string*' }| Sort 4