Need to exclude Exchange 2016 server from scripting RRS feed

  • Question

  • Hi,

    I got awesome script to monitor exchange server's database health


    I have edited <g class="gr_ gr_193 gr-alert gr_gramm gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" data-gr-id="193" id="193">script</g>, its working fine.


    [Bool] $bolFailover=$False

    [String] $errMessage=$null

    $date = get-date

    $subject =  "Database Health Check !!!" + $date

    $errMessage+="## Checking if any Database is not mounted as per Activation Preference 1 ##"


    Get-MailboxDatabase | ForEach {



           $ownServer=$_.ActivationPreference | ? {$_.Value -eq 1}

           # Compare the server where the DB is currently active to the server where it should be

           If ($curServer-ne $ownServer.Key.Name) {

                         $errMessage+="`n$db on $curServer should be on $($ownServer.Key)"





    $errMessage+="## Checking if any Database or Content Index is not healthy ##"

    Get-MailboxDatabaseCopyStatus * | ForEach { 

           If ($_.Status -notmatch "Mounted" -and $_.Status -notmatch "Healthy" -or $_.ContentIndexState -notmatch "Healthy") {

                  $errMessage+="`n`n$($_.Name)  |  Status: $($_.Status)  |  CQL: $($_.CopyQueueLength)  |  RQL: $($_.ReplayQueueLength)  |  ContentIndex: $($_.ContentIndexState)"



    If ($bolFailover) { 

           Send-MailMessage -From "" -To "" -Subject $subject -Body $errMessage -SMTPserver ""


    However I would like to exclude Exchange 2016 databases from monitoring for a while.

    How would i do that ?

    Friday, August 5, 2016 10:37 AM

All replies

  • Hi

    You have a command that lists all - Get-MailboxDatabaseCopyStatus * , you can try change this to 1 server or Database. 

    Edward van Biljon - Exchange MVP

    Friday, August 5, 2016 4:45 PM
  • Hi,

    @Edward van Biljon

    I am able to exclude single database or single server. But I would like to exclude a bunch of exchange 2016 servers from monitoring. Would it be possible to edit above script according to my requirement ?

    Wednesday, August 10, 2016 7:51 AM
  • Get-exchangeserver |?{$_.some excluding criteria} |get-mailboxdatabase |foreach { ...}
    Monday, August 22, 2016 1:52 PM