Solved

Need help with exchange powershell script

Posted on 2010-09-23
7
567 Views
Last Modified: 2012-05-10
I am working on a script that will write to the event log a error when my exchange 2010 database is not mounted on the prefered server. Here is the function I have written to check if the databvase is "Mounted" on the prefered server.

I added a write-output to check that my $Mounted is getting the proper result and it is but the function is always returning false.

function IsDatabaseMounted
{
      $Mounted = Get-MailboxDatabaseCopyStatus "MBX01\sever1" | fl status
      write-output $Mounted
      if ($Mounted  -eq "Status : Mounted"){
      
            return $true;
            
      }else{
            return $false
      }      
}
0
Comment
Question by:Gary Dewrell
  • 4
  • 3
7 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 33749467
try:$Mounted.Status -eq ...
0
 
LVL 12

Author Comment

by:Gary Dewrell
ID: 33749511
If your saying replace

 if ($Mounted  -eq "Status : Mounted"){

with

if ($Mounted.Status -eq  "Status : Mounted"){

That did not work.
0
 
LVL 12

Author Comment

by:Gary Dewrell
ID: 33749532
Ah but you did point me in the correct direction.
The below worked.


function IsDatabaseMounted
{
      $Mounted = Get-MailboxDatabaseCopyStatus "PDI-Temple-MBX01\server1"
      write-output $Mounted.status
      if ($Mounted.status -eq "Mounted"){
      
            return $true;
            write-output "TRUE!!!!!"

      }else{
            return $false
      }      
}
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 12

Author Closing Comment

by:Gary Dewrell
ID: 33749538
Not the whole answer but you got me pointed int the right direction. Thanks!
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 33749539
remove the fl status:


function IsDatabaseMounted
{
      $Mounted = Get-MailboxDatabaseCopyStatus "MBX01\sever1" 
      
      if ($Mounted.Status  -eq "Mounted"){
      
            return $true;
            
      }else{
            return $false
      }      
}

Open in new window

0
 
LVL 42

Expert Comment

by:sedgwick
ID: 33749541
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 33749549
you were ahead of me... as long as you got it working :)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This video discusses moving either the default database or any database to a new volume.

895 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now