Quantcast
Channel: Exchange Server 2010 forum
Viewing all articles
Browse latest Browse all 8820

Automating an email containing ReplicationHealth status

$
0
0

Hi all. From the Exchange Management Shell, if I run the Test-ReplicationHealth command, I get a nice list of everything its checked, and the result (thankfully, always passed).

I would like to automate this, and have a powershell script email me the results. I've successfully already done this with DFS replication backlog, but what I learned there, doesn't seem to be working in this case. No doubt because it's Exchange.

The script I am using is;

# Create a function that lets PowerShell call the Exchange Snapin

function Load_Exchange_Tools {
	if (-not (Get-pssnapin | ? {$_.name -like 

'Microsoft.Exchange.Management.PowerShell.e2010'})) {
		Add-PSSnapin Microsoft.Exchange.Management.PowerShell.e2010
	}
}

# Exchange Snapin loaded

$body += '-'*20
$body += 'SERVER1NAME'
$body += Test-ReplicationHealth -Identity SERVER1NAME

$body += '-'*20
$body += 'SERVER2NAME'
$body += Test-ReplicationHealth -Identity SERVER2NAME

$body = $body | out-string

$email = @{
From = "email@domain.com"
To = "email@domain.com"
Subject = "Exchange DAG Replication Status"
SMTPServer = "servername.domain"
Body = $body
}

send-mailmessage @email


However, when it runs, instead of the 'Passed' (or other, if there's an issue), I get this, and the results are all over the place.

--------------------SERVER1NAMEMicrosoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome--------------------SERVER2NAMEMicrosoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome Microsoft.Exchange.Monitoring.ReplicationCheckOutcome 

Any advice on how to get this working will be greatly appreciated and I'm happy to share the DFS script if anyone is interested :)

TIA Shane.




Viewing all articles
Browse latest Browse all 8820

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>