SahinBoluk
asked on
Activate DB on different server if mounted
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-MailboxDatabaseCo pyStatus -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.
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-MailboxDatabaseCo
if ($db1[0].Status -eq "mounted")
{
Move-ActiveMailboxDatabase
}
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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER