1

I have some User objects with "ExchangeActiveSyncDevices" object within. I also have some Computer objects with published printers inside.

So how can I look (with PowerShell) for such objects using some kind of unified approach? I mean without specific Exchange commandlets for AS devices and such. There must be a way to find objects with another object inside using some [ADSI] magic or such, right?

user2838376
  • 191
  • 1
  • 5
  • 16

2 Answers2

1

You can use the SearchBase of the parent Object to find Child Objects, for example:

Get-ADUser -Filter *|
ForEach-Object{
    $childObj = Get-ADObject -Filter * -SearchBase $_.DistinguishedName
    [PSCustomObject]@{
        ComputerName = $_.Name
        ChildCount =  $childObj.Count
        msExchActiveSyncDevice = $childObj | Where-Object {$_.ObjectClass -eq "msExchActiveSyncDevice"}
    }
}
jfrmilner
  • 476
  • 2
  • 6
0

Use could try the Get-ADObject cmdlet to search for objects in Active Directory and filter the results using the -Filter parameter. The filter should be in the LDAP query format and you can use the -Properties parameter to specify which properties of the object you want to retrieve. Probably like this:

Get-ADObject -Filter {objectClass -eq "user" -and msExchActiveSyncDevices -ne $null} -Properties msExchActiveSyncDevices

Christiyan
  • 26
  • 3