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
58 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

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…
In-place Upgrading Dirsync to Azure AD Connect
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

756 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