Using PowerShell to find last DirSync

When troubleshooting DirSync issues with Office 365, it is sometimes difficult to know if the DirSync successfully applied to Office 365.

There is a quick way to check this and it provides the data for when the update last took place. First you will need to make sure that you have installed the Azure AD Module for PowerShell, you can download from here.

When this has installed, run Connect-MsolService to connect to the Office 365 tenancy, this should be a global administrator account.

Azure Connect PowerShell

Then run Get-MsolCompanyInformation to get the tenancy information which includes the last dirsync time and last password sync

6 thoughts on “Using PowerShell to find last DirSync

  1. Scotepi

    Put it in your time zone ($LastDirSyncTime) and give the age ($LastDirSyncAge)

    $strCurrentTimeZone = (Get-WmiObject win32_timezone).StandardName
    $TZ = [System.TimeZoneInfo]::FindSystemTimeZoneById($strCurrentTimeZone)
    $LastDirSyncTime = [System.TimeZoneInfo]::ConvertTimeFromUtc((Get-MsolCompanyInformation).LastDirSyncTime, $TZ)
    $LastDirSyncAge = (Get-Date) – $LastDirSyncTime



Leave a Reply

Your email address will not be published. Required fields are marked *