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
60 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article explains how to install and use the NTBackup utility that comes with Windows Server.
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
To show how to generate a certificate request 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 Servers >> Certificates…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

740 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