1 Reply Latest reply on Apr 6, 2017 2:54 PM by st.crispan

    Need help in seting up an alert for exchange queue

    kuchauha@ciena.com

      Hi, I need to set up an alert for Exchange server. Any time exchange queue (which is a file) contain more than  or about to reach 200 messages. It will generate an alert. I’m hoping the Exchange monitor should have that functionality ? Any help /suggestion is appreciated.

        • Re: Need help in seting up an alert for exchange queue
          st.crispan

          I went looking for such a script.  Recently came across something provided by Solarwinds tech while troubleshooting mailbox size.  This script was lifted from the AppInsight itself.

           

          You can run this script on an Exchange box which has the correct PowerShell modules loaded.  Also, replace "Mailbox-name" and "$USER" with the name of the box you're trying to get info on.  Also, you need to have the minimum permissions on the box as if you were going to be running the Exchange AppInsight, that being the Read-Only Role and the Mailbox Search Roles.  If you remove the "-ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue" error checking, it becomes easier to read, by the way.

           

          <code>

          $SearchName = "Mailbox-Name"

          $QueryCheck = Get-MailboxSearch -Identity "$SearchName" -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue

          If ($QueryCheck -eq $null) {New-MailboxSearch -Name "$SearchName" -EstimateOnly -SearchQuery "$Attachments" -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue} else {Set-MailboxSearch -Identity "$SearchName" -EstimateOnly:$True -SearchQuery "$Attachments" -SourceMailboxes $Null -EndDate $null -StartDate $Null -Senders $Null -Recipients $Null -MessageType $Null -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue}

          Stop-MailboxSearch -Identity "$SearchName" -Confirm:$false -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue

          Sleep 5

          $Usr = Get-Mailbox -Identity "$USER"

          Set-MailboxSearch -Identity "$SearchName" -SourceMailboxes "$Usr" -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue

          $NewCheck = Get-MailboxSearch -Identity "$SearchName" -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue

          If ($NewCheck.Status -ne "EstimateInProgress") {Start-MailboxSearch -Identity "$SearchName" -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue -Confirm:$false}

          Do {Sleep 0.1; $Stat = Get-MailboxSearch -Identity "$SearchName" -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue} While ($Stat.Status -ne "EstimateSucceeded")

          $Attach = Get-MailboxSearch -Identity "$SearchName" -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue | Select-Object SourceMailboxes, ResultNumberEstimate, ResultSizeEstimate

          Set-MailboxSearch -Identity "$SearchName" -EstimateOnly:$True -SearchQuery $Null -SourceMailboxes $Null -EndDate $null -StartDate $Null -Senders $Null -Recipients $Null -MessageType $Null -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue

          Stop-MailboxSearch -Identity "$SearchName" -Confirm:$false -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue

          </code>