LDAP query leaf object

R3K3 41 Reputation points
2020-11-12T19:07:05.92+00:00

Looking for a way to use Powershell to query leaf objects of an AD account. In particular, I am trying to query the ExchangeActiveSync leaf objects under a user account in AD. I am able to query the AD account in Powershell itself, but not sure about a way to view the leaf objects of that account.

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | PowerShell
{count} votes

3 additional answers

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2020-11-12T19:33:33.057+00:00

    Is there a reason you aren't using the Exchange cmdlets to do this?

    I'm pretty sure the cmdlet Get-CASMailbox would return what you need.

    0 comments No comments

  2. R3K3 41 Reputation points
    2020-11-12T20:25:50.593+00:00

    The data for ActiveSync connections is stored in the leaf objects, every so often I have users that build up a large number of these due to ActiveSync code and they need to be erased. Using Exchange is too slow to run this query against thousands of users, my environment is fortune 20 level. When I run the following command I can see ActiveSync connections in Exchange..

    Get-ActiveSyncDeviceStatistics -Mailbox $user | sort LastSuccessSync -Descending | ft LastSuccessSync,DeviceType,DeviceModel,DeviceOS,Guid,Status

    I am trying to delete the ones in the above list that have a LastSuccessSync date of older than X days, say 30 in this example. I would much rather have this run at the LDAP level than on my Exchange servers.


  3. R3K3 41 Reputation points
    2020-11-13T20:16:51.253+00:00

    Nice. Thanks, that gave me the ideas I needed.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.