Score:1

Powershell - how to scan Active Direcotry for nested objects?

in flag

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?

Score:1
ar flag

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"}
    }
}
Score:0
pk flag

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

user2838376 avatar
in flag
That's the problem - it's not property of the class, it's object within object. So this approach won't work
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.