This is a guest post my Mr. Troy Collins
When mail queues get big mail flow may stop working.. This script can be very helpful and should be added to Schedule task to run every 15 minutes.
<#
This script will test Exchange mail queues and e-mail if amount of message are too many.
Writen by Troy Collin
#>
$server = hostname
#$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$server/powershell/ -Authentication Kerberos
#Import-PSSession $Session
add-pssnapin Microsoft.Exchange.Management.PowerShell.SnapIn
Write-host "Exchange Snapin now eanbled."
$total_messages = get-transportserver| get-queue | foreach -begin {$total=0} -process {$total+=$_.messageCount} -end {$total}
if ($total_messages -gt 200)
{
write-host "messages are high"
$total_messages
$message = "`n*******Automated E-mail DO NOT REPLY******`n
Exchange Message Queues test. `n
`n`nAlert Check message queue!!
current total is $total_messages`n `n
Thank you"
$emailFrom = "Mail Queue problem! <Sender@sender.com>"
$smtpServer = "SMTPServer"
#$emailTo = "to@to.com"
$emailSubject = "Mail Queue Status script"
$file = "$Filename"
######### End of Send email variables ###############
$mailMessageParameters = @{
From = $emailFrom
To = $emailTo
Subject = $emailSubject
SmtpServer = $smtpServer
Body = $message
# Attachment = $REPORT
}
Send-MailMessage @mailMessageParameters
} else {
Write-host "messages are not high"
$total_messages
}
Am I the only person, who has problems with this script? It doesn't work at all. I would be very grateful, if someone helped me.
ReplyDeleteI will reach out to the creator and ask him if he can revisit it.
DeleteThanks for bringing this to my attention.
Greetings, there might be a problem with what version of MS exchange the script is running against. I just ran it on a lab system Exchange 2013 and it does work. however it seems it will not work after exchange 2013.
Delete.\test.ps1
Exchange Snapin now eanbled.
Creating a new session for implicit remoting of "Get-TransportServer" command...
WARNING: The Get-TransportServer cmdlet will be removed in a future version of Exchange. Use the Get-TransportService
cmdlet instead. If you have any scripts that use the Get-TransportServer cmdlet, update them to use the
Get-TransportService cmdlet. For more information, see http://go.microsoft.com/fwlink/p/?LinkId=254711.
messages are not high
0
This comment has been removed by the author.
ReplyDelete