So, you are preparing to deploy the Directory Synchronization tool for Office 365 and are looking for a PowerShell script that will count all of the users, groups, and contacts in the on-premises Active Directory.  First, I should point out that the Deployment Readiness Tool that is available for download from the Office 365 community site will count the objects plus perform additional useful checks.  If, however, you still want a PowerShell script that is dedicated to only counting objects, then look no further.  This script does not require additional software to run (other than PowerShell).  It does, however, require read-only access to the on-premises Active Directory.  The results of the script will be displayed to the PowerShell console as well as saved to a CSV file.  Enjoy…

A copy of the script can be downloaded by clicking the link below.