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 2021you can use the-Identityparameter as Mathias R. Jessen points out. If you want to query the group membership, you can useGet-ADGroupMember, or you can query theMemberattribute of the group:This query can be also reversed, we can use
LDAPFilterto search for all users whoseMemerOfattribute contains theDistinguishedNameof the Fall 2021 group and whoseDescriptionattribute is equal to Customer: