I'm trying to get all AD users in the AD group 'Fall 2021' where the description is like 'Customer.' I'm currently receiving this error when I run my script. Any help or guidance is much appriciated.
Get-ADGroup : Error parsing query: 'Fall 2021' Error Message: 'syntax error' at position: '1'.
At line:1 char:1
+ Get-ADGroup -filter "Fall 2021" | Where-Objec ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ParserError: (:) [Get-ADGroup], ADFilterParsingException
+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADFilterParsingException,Microsoft.ActiveDirectory.Management.Commands.GetADGroup
Here is the script:
Get-ADGroup -filter "Fall 2021" | Where-Object {$_.Description -like 'Customer' }
-Filter "Fall 2021"
is not a valid syntax for the AD Filter, if the Name of the group isFall 2021
you can use the-Identity
parameter as Mathias R. Jessen points out. If you want to query the group membership, you can useGet-ADGroupMember
, or you can query theMember
attribute of the group:This query can be also reversed, we can use
LDAPFilter
to search for all users whoseMemerOf
attribute contains theDistinguishedName
of the Fall 2021 group and whoseDescription
attribute is equal to Customer: