How to Determine Last Failover Time in SQL Server Availability Group

availability-groupssql serversql server 2014

I'd just like to know if there is any way to query when the AG group failed over.

eg – this is the Primary Replica now, but I'm pretty sure it was the secondary yesterday? How can i find when the failover took place

is there something specific in the Logs I should be looking for, or is there a tsql script to use?

Best Answer

You can use following PowerShell script to get last failover time

    Get-winEvent -ComputerName ListnerName -filterHashTable @{logname ='Microsoft-Windows-FailoverClustering/Operational'; id=1641}| ft -AutoSize -Wrap