Recently I needed to create a quick report that would allow me to see at a glance which accounts in that domain had been synchronised with AD Sync into Azure AD.  It wasn’t possible using Get-ADuser and I knew an LDAP query would do the trick.  First I had to download a powershell module called System.DirectoryServices.Protocols.  Once the module is downloaded run:

Then to query the information I required I ran:

Conversely, if you wanted to find all users that HADN’T been synchronised you could run the following:

I still had a few service accounts showing so I just filtered these in Excel based on the DN.  To export the file just run…