Hi All,
I am looking for a script where if the db has been failed over to passive node we should get an alert on it.
$logfile = $logdir + "DBStatus.log"
$log = ""
$DAG=Get-MailboxDatabase |Where-Object {$_.ReplicationType -Like "Remote" -and $_.MasterServerOrAvailabilityGroup -Like "$DAG"} |Sort-Object Name
foreach ( $i in $DAG)
{
$DB=$i.Name
$xNow=$i.Server.Name
$dbown=$i.ActivationPreference| Where {$_.Value -eq 1}
#Write-output "DB Name-" $DB
#Write-output "DB Mounted on server"$xnow
#Write-output $dbown
If ($xNow -ne $dbOwn.Key)
{
$log += $DB+" Mounted in Passive copy "+$xNow+";"+$DB+" should be mounted on "+$DBown.Key
$count=$count+1
$log+= "`n"
}
}
If ($count -ne 0)
{
$Test="Databases running on Passive Node servers"
$log += $Count,$Test
}
else
{
$log += "All the databases running on correctly !!!"
}
logToFile $logfile $log
Send-MailMessage -To $emailTo -From $emailfrom -SmtpServer $smtpServer -Body $log -Subject "$DAG DAG Mount Status $date"
But it is not working as expeted can you please review on it
Regards
Muthu
Thanks Muthu