AADConnect Last Sync Time - locally, WITHOUT Msol

Eve Meier 21 Reputation points
2020-12-30T09:28:30.817+00:00

Hi,

We are trying to monitor last dir sync time on AADC Servers for our customers.
We would like to achieve this locally so we dont need to have credentials to use Connect-MsolService.

I had this up and running for a few months:

 $connector = get-adsyncConnector | Where-Object {$_.name -like "*onmicrosoft*"} | Select-Object name  
  
 $tenant = $connector.Name  
   
$LastSuccessRunTime = Get-CimInstance -ComputerName $env:computername -ClassName MIIS_RunHistory -Namespace "root\MicrosoftIdentityIntegrationServer" -Filter "RunProfile = 'Export' AND MaName = '$Tenant' AND RunStatus = 'success'" | Sort-Object runendtime | Select-Object -Last 1 runendtime  

Unfortunately since a few days, i assume after some kind of update we made, i get an error.. i tried to check:

52301-image.png

I cant seem to fix this and need your ideas :)

Thanks in advance!

Eve Meier

Windows Server Management
Windows Server Management
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Management: The act or process of organizing, handling, directing or controlling something.
424 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,397 questions
{count} votes

Accepted answer
  1. Nuno Alexandre 86 Reputation points Microsoft Employee
    2020-12-31T02:04:59.34+00:00

    WMI has been deprecated in version 1.4.18 in favor of PowerShell. You can now get the run history with Get-ADSyncRunProfileResult, for example:

    Get-ADSyncRunProfileResult | sort RunNumber,CurrentStepNumber -Descending | select -First 1 | select RunProfileName, Result, StartDate, EndDate

    52323-image.png

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Andy David - MVP 144.4K Reputation points MVP
    2020-12-30T13:09:10.6+00:00

    You could just check the event log entry that fires on the server when the AADConnect export is complete.

    52262-image.png