0
votes

I am looking for all accounts that have “(FUR)” in the begging of their AD account description. I need these for any and all OUs under Office/Users. All of these accounts that Have “(FUR)” in the description, I need the following exported;

  • User Logon Name
  • Description
  • extensionattribute11

This is what I have come up with so far:

Import-Module ActiveDirectory;
$creds = Get-Credential
$OUPath = 'OU=Standard Users,OU=NY,OU=users,OU=Offices,DC=US,DC=FLN,DC=NET'
Get-ADUser -Properties Description -Filter "(FUR)" -SearchBase $OUPath

This is the error I get:

Get-ADUser : Error parsing query: '(FUR)' Error Message: 'syntax
error' at position: '5'. At line:2 char:1
+ Get-ADUser -Properties Description -Filter "(FUR)" -SearchBase $OUPat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ParserError: (:) [Get-ADUser], ADFilterParsingException
    + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADFilterParsingException,Microsoft.ActiveDirectory.Management.Commands.GetADUser
1
Perhaps you need to escape the parenthesis e.g -Filter "\(FUR\)"?Cyclonecode

1 Answers

2
votes

When using the -Filter parameter, you must pass a string that contains the syntax propertyName -operator value.

Get-ADUser -Properties Description -Filter "Description -like '(FUR)*'" -SearchBase $OUPath

(FUR)* would match a value that begins with (FUR). You would need to use *(FUR)* if you do not know where (FUR) exists within the value.

See Get-ADUser for a more in-depth description.