Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Activate DB on different server if mounted

Posted on 2013-10-22
3
Medium Priority
?
268 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to effectively resolve the number one email related issue received by helpdesks.
If you have come across a situation where you need to find some EDB mailbox recovery techniques, then here you will find the same. In this article, we will take you through three techniques using which you will be able to perform EDB recovery. You …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

963 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