Ms exchange 2010 high queue alert

Ms exchange 2010 high queue alert. What can i do on exchange 2010 so that i can get alerts when it reaches more then 10 messages in queue

What is the best practice?
Member_2_6474242Senior Systems AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MASEE Solution Guide - Technical Dept HeadCommented:
Hi Member_2_6474242,
Please find below script to send email when it reaches threshold of 10.

# Script:    Exch2010QueueMonitor.ps1 
# Purpose:  This script can be set as a scheduled task to run every 30minutes and will monitor all exchange 2010 queue's. If a threshold of 10 is met an  
#            output file with the queue details will be e-mailed to all intended admins listed in the e-mail settings 
# Author:    
# Email:    youremail@email.com
# Date:     May 2011 
# Comments: Lines 27, 31-35 should be populated with your own e-mail settings 
# Notes:     
#            - tested with Exchange 2010 SP1 
#            - The log report output file will be created under "c:\temp\qu.txt" 
 
$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://YourCASServerFQDN/PowerShell/ -Authentication Kerberos 
Import-PSSession $s 
 
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 
. $env:ExchangeInstallPath\bin\RemoteExchange.ps1 
Connect-ExchangeServer -auto 
 
$filename = “c:\temp\qu.txt” 
Start-Sleep -s 10 
if (Get-ExchangeServer | Where { $_.isHubTransportServer -eq $true } | get-queue | Where-Object { $_.MessageCount -gt 10 }) 
 
{ 
 
Get-ExchangeServer | Where { $_.isHubTransportServer -eq $true } | get-queue | Where-Object { $_.MessageCount -gt 10 } | Format-Table -Wrap -AutoSize | out-file -filepath c:\temp\qu.txt 
Start-Sleep -s 10 
 
$smtpServer = “xxx.xxx.xxx.xxx” 
$msg = new-object Net.Mail.MailMessage 
$att = new-object Net.Mail.Attachment($filename) 
$smtp = new-object Net.Mail.SmtpClient($smtpServer) 
$msg.From = “Monitor@contoso.com” 
$msg.To.Add("admin1@mycompany.com") 
#$msg.To.Add("admin2@mycompany.com") 
#$msg.To.Add("admin3@mycompany.com") 
#$msg.To.Add("admin4@mycompany.com") 
$msg.Subject = “CAS SERVER QUEUE THRESHOLD REACHED - PLEASE CHECK EXCHANGE QUEUES” 
$msg.Body = “Please see attached queue log file for queue information” 
$msg.Attachments.Add($att) 
$smtp.Send($msg) 
 
}

Open in new window

Member_2_6474242Senior Systems AdministratorAuthor Commented:
Thanks MAS EE MVE

Can you please clarify. It is only connecting VERBOSE. Is that ok. This will only work when there is a queue right.

give a warning. the names of some imported commands from the module 'tmp_npo44qgd.154' include unapproved verbs that might make them less discover-able. to find the commands with unimproved verbs, run the import module command again with the verbose parameter. for a list of approved verbs, type Get-verb

i have attached error message

Please note i am a beginner in powershell
erroronqueuestats.txt
Senior IT System EngineerIT ProfessionalCommented:
You can try to use the below script which you can also customize it yourself:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://YourExchangeServer.domain.com/PowerShell/ -Authentication Kerberos
Import-PSSession $Session -AllowClobber
Import-Module ActiveDirectory -ErrorAction STOP

While ($true) {
	$Queue = Get-TransportServer |
		ForEach-Object {Get-Queue -Server $_} |
		Where-Object {($_.MessageCount -gt 0) -and ($_.Identity -notlike "*\Poison") -and ($_.Identity -notlike"*\Shadow\*")} |
		Select-Object Identity, Status, MessageCount, NextHopDomain
	$QueueLength = $Queue | Measure-Object MessageCount -Sum | Select-Object -ExpandProperty Sum
	"[$(Get-Date -Format 'yyyy-MM-dd hh:mm:ss')] Queues found: $($Queue.Count); messages: $($QueueLength)." | Write-Host -ForegroundColor White
	$Subject = ''
	If ($QueueLength -gt 200) {
		$Subject = "Attention Critical Exchange Queue Alert Total Message Queue $QueueLength"
		$Color = 'Red'
	} ElseIf ($QueueLength -gt 100) {
		$Subject = "Attention Warning Exchange Queue Alert Total Message Queue $QueueLength"
		$Color = 'Yellow'
	} ElseIf ($QueueLength -gt 10) {
		$Subject = "Attention Informational Exchange Queue Alert Total Message Queue $QueueLength"
		$Color = 'White'
	}
	If ([string]::IsNullOrEmpty($Subject)) {
		"[$(Get-Date -Format 'yyyy-MM-dd hh:mm:ss')] Exchange is pretty much idle ..." | Write-Host -ForegroundColor Green
	} Else {
		"[$(Get-Date -Format 'yyyy-MM-dd hh:mm:ss')] $($Subject)" | Write-Host -ForegroundColor $Color
		Send-MailMessage `
			-Subject $Subject `
			-Body $($Queue | ConvertTo-HTML | Out-String) `
			-From "Powershell@domain.com" `
			-To "Admin@domain.com" `
			-SmtpServer "smtp.domain.com" `
			-BodyAsHtml 
	}
	Start-Sleep -Seconds 120
}

Open in new window

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

AmitIT ArchitectCommented:
I advise you to review your threshold requirement. 10 mails is too low for any mail server. I will set alert, if anything goes about 150-200. Rest, you have tons of script or tools to get the alert. However, remember, if your Exchange server itself having issues, you won't get the alert. Better to use 3rd party tool to monitor your server.
Member_2_6474242Senior Systems AdministratorAuthor Commented:
what are some of the tools that can be used for this purpose?
AmitIT ArchitectCommented:
ITSM, SCCM, website pulse.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Member_2_6474242Senior Systems AdministratorAuthor Commented:
thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.