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
53 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
ID: 40585400
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
ID: 40585978
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
ID: 40587667
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

863 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

26 Experts available now in Live!

Get 1:1 Help Now