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

x
?
Solved

Need help with exchange powershell script

Posted on 2010-09-23
7
Medium Priority
?
577 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:
Meir Rivkin earned 1500 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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:Meir Rivkin
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:Meir Rivkin
ID: 33749541
0
 
LVL 42

Expert Comment

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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Steps to fix error: “Couldn’t mount the database that you specified. Specified database: HU-DB; Error code: An Active Manager operation fail”
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

971 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