Powershell exchange 2013 submission queue

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
jhowland
Posts: 1
Joined: Tue Jun 07, 2016 6:15 am

Powershell exchange 2013 submission queue

Post by jhowland »

I am trying to create a script that hostmon can use to get the amount of email in a submission queue. I just need it to return the results of “get-queue submission | select messagecount�. If the result is over 100 send a alert. Can you assist me, I cannot figure out how to script this in your program.

Requirements
Server parameter
Script

Need to return the numerical value
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

You need to use Shell Script test method: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell

Script for Shell Script test may look like the following:

Code: Select all

$statusUnknown     = "ScriptRes:Unknown:"
$statusOk          = "ScriptRes:Ok:"
$statusBad         = "ScriptRes:Bad:"


if ($args.Count -ne 1) {
  echo  $statusUnknown"Message count threshold is required"
  exit
}

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn

[int]$msgLimit = $args[0]
[int]$msgCnt = $(get-queue submission).MessageCount
  
if ($msgCnt -gt $msgLimit)
{
   echo $statusBad$msgCnt
} 
else 
{
   echo $statusOk$msgCnt
}
Start cmd: C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe %script% %params%
Script requires 1 parameter - message count threshold
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Improved script (with exception handling):

Code: Select all

$statusUnknown     = "ScriptRes:Unknown:"
$statusOk          = "ScriptRes:Ok:"
$statusBad         = "ScriptRes:Bad:"

if ($args.Count -ne 1) {
  echo  $statusUnknown"Message count threshold is required"
  exit
}

Try
{
Add-PSSnapin Microsoft.Exchange.*

[int]$msgLimit = $args[0]
[int]$msgCnt = $(Get-Queue -Identity submission).MessageCount
} catch {
  echo  $statusUnknown$_.Exception.Message
  Break
}
 
if ($msgCnt -gt $msgLimit)
{
   echo $statusBad$msgCnt
}
else
{
   echo $statusOk$msgCnt
}
Start cmd: C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe %script% %params%
Script requires 1 parameter - message count threshold
Post Reply