Link to home
Start Free TrialLog in
Avatar of GJohn32
GJohn32Flag for United States of America

asked on

DIRECTORY SERVICES -Filter an ADSI Attribute

(Exchange 2010)

Hello all,
My goal is to locate all the employees in the company and add an Exchange Custom Attribute.  Now the only field that identifies the user as an employee is in ADSI Edit, which was updated thru a Schema change.  

When I run the following cmd below in EMS, it appears to complete but does not not add 'Employee' to EMC Custom Attribute4


$Searcher = New-Object -Typename DirectoryServices.DirectorySearcher ($domain = [ADSI]"")
$Searcher.filter = "(&(objectClass=user)(HRPro=TRUE))"
$userResult = $Searcher.findall()
$Empl = $userResult
<#

######################################
$Empl | Foreach{
      $Entry = $_.GetDirectoryEntry()
      $DN = ($Entry.DistinguishedName).ToString()
      $scriptpath = ($Entry.scriptpath).ToString()
      Set-Mailbox $DN -CustomAttribute4 “Employee”}
#>

Avatar of GJohn32
GJohn32
Flag of United States of America image

ASKER

If I run a partial cmd, it does work and provides me with the number of employees that have TRUE in ADSIEdit.  I'm not sure how to connect both cmds where I can retrieve the employees and add the custom attribute in EMC.


$Searcher = New-Object -Typename DirectoryServices.DirectorySearcher ($domain = [ADSI]"")
$Searcher.filter = "(&(objectClass=user)(HRPro=TRUE))"
$userResult = $Searcher.findall()
$userResult.count
ASKER CERTIFIED SOLUTION
Avatar of GJohn32
GJohn32
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial