Solved

I need to do some activity on exchange server which can be counted as an value add to my organisation

Posted on 2015-02-02
3
51 Views
Last Modified: 2015-02-19
Hi Team,

I need to do some activity in exchange server 2010 which can be counted as an value add to my organization.
For example, One of my colleague has make a script for exchange health monitoring. I also need to do some activity or prepare some script which is beneficial for my team in exchange server 2010.
0
Comment
Question by:Manish Kumar
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
Rezwan Islam earned 500 total points
Comment Utility
I have got a little one if you are using DAG. You can use the following script to automate DAG failback and send out an alert.

#================start-of-script=======================

Function sendEmail ([String] $body)
{
      $MailMessage = New-Object System.Net.Mail.MailMessage
      $MailMessage.From = "exchange-dag@yourdomain.com"
      $MailMessage.To.Add("user1@yourdomain.com,user2@yourdomain.com,user3@yourdomain.com")
      $MailMessage.Subject = "Exchange DAG Not Healthy! switchback has now been initiated."
      $MailMessage.Body = $body
      $MailMessage.Priority = "High"

      $SMTPClient = New-Object System.Net.Mail.SMTPClient
      $SMTPClient.Host = "smpt.yourdomain.com"
      $SMTPClient.Send($MailMessage)
}

[Bool] $bolFailover = $False
[String] $errMessage = $null

Get-MailboxDatabase | Sort Name | ForEach {
      $db = $_.Name
      $xNow = $_.Server.Name
      $dbOwn = $_.ActivationPreference | ? {$_.Value -eq 1}

      If ($xNow -ne $dbOwn.Key)
      {
            $errMessage += "`n$db on $xNow should be on $($dbOwn.Key)!"
            $bolFailover = $True
            Start-Sleep -Seconds 5
            Move-ActiveMailboxDatabase -Server $xNow -Confirm:$false
      }
      
}

$errMessage += "`n`n"

Get-MailboxServer | Get-MailboxDatabaseCopyStatus | ForEach {
      If ($_.Status -notmatch "Mounted" -and $_.Status -notmatch "Healthy" -or $_.ContentIndexState -notmatch "Healthy")
      {
            $errMessage += "`n$($_.Name) - Status: $($_.Status) - Index: $($_.ContentIndexState)"
            $bolFailover = $True
      }
}

If ($bolFailover) { sendEmail $errMessage }

#=================end-of-script=======================
0
 
LVL 1

Author Comment

by:Manish Kumar
Comment Utility
Hi Rezwan,

it is really nice. May i know how to run this and how can automate this so that it can work without any manual intervention.
0
 
LVL 3

Expert Comment

by:Rezwan Islam
Comment Utility
You can create a CMD file using the following context and then set up a schedule task to call the CMD file to automate this failback process.

Paste the above script in a notepad and save as NotifyDBFailover.ps1. Paste the following batch commands in a notepad and save it as a NotifyDBFailover.CMD file and keep both these files under a folder called, lets say, C:\Scripts

#================CMD-FILE-CONTYEXT=============
@echo off
Powershell.exe -Command ".'C:\Program Files\Microsoft\Exchange Server\V14\Bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; C:\scripts\NotifyDBFailover.ps1"

#===============CMD-FILE-END===================

Then on the schedule task Action tab, select
Action: Start a program
Under Settings section, program/script: C:\Scripts\NotifyDBFailover.cmd
Start in (Optional): C:\Scripts

You can set a trigger for every 30 minutes.

Hope this helps.
0

Featured Post

Do email signature updates give you a headache?

Do you feel like you are constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

Join & Write a Comment

Resolve DNS query failed errors for Exchange
Easy CSR creation in Exchange 2007,2010 and 2013
In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now