Solved

Activate DB on different server if mounted

Posted on 2013-10-22
3
261 Views
Last Modified: 2013-10-27
Hi,

I'm trying to write a script that will check to see if a DB is mounted on a specific server, and if it is mounted, activate it on a different server.  Below is what I have so far, but not working:

$dd1=Get-MailboxDatabaseCopyStatus -Server xxxx
if ($db1[0].Status -eq "mounted")
{
      Move-ActiveMailboxDatabase -ActivateOnServer yyyy -MountDialOverride 'none' -Confirm:$False
}
else
{
exit
}

The error that I am getting is :

Cannot index into a null array.
At C:\DBSwitch.ps1:2 char:10
+ if ($db1[ <<<< 0].Status -eq "mounted")
    + CategoryInfo          : InvalidOperation: (0:Int32) [], RuntimeException
    + FullyQualifiedErrorId : NullArray


I'm thinking that it doesn't like my variable declaration.

I can do it another way, but that would require me to "manually" enter each DB name.  This is not what I am looking for as I need to make this a scheduled task.
0
Comment
Question by:SahinBoluk
  • 2
3 Comments
 
LVL 9

Assisted Solution

by:Mahesh Sharma
Mahesh Sharma earned 500 total points
ID: 39591320
If you are using Exchange 2010 with DAG, utilize this script for DAG health check

http://gallery.technet.microsoft.com/office/Exchange-DAG-Replication-d8e99705
0
 
LVL 1

Accepted Solution

by:
SahinBoluk earned 0 total points
ID: 39591623
Thanks,

I got an idea from that script.  My new script looks like this:

$dd2 = get-mailboxserver -Identity "server name" | where-object{$_.AdminDisplayVersion.major -eq "14" -AND $_.DatabaseAvailabilityGroup -ne $null} | Get-MailboxDatabaseCopyStatus -ConnectionStatus | ?{$_.activecopy -eq "True"}
foreach($dd2 in $dd2)
{
      Move-ActiveMailboxDatabase -Identity $dd2.databasename -ActivateOnServer "Server Name" -MountDialOverride 'none' -Confirm:$False
}

This works!  thanks for the "Push" :-).
0
 
LVL 1

Author Closing Comment

by:SahinBoluk
ID: 39603608
Mks_ directed me to a script which I can use to guide me on creating a working script.  I have copied the script that works for anyone else that needs it.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Find out what you should include to make the best professional email signature for your organization.
In this video we show how to create a Distribution Group 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 >>…
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…

773 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