Solved

Need help with exchange powershell script

Posted on 2010-09-23
7
566 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Integrate social media with email signatures

Is your company active on social media? Do you also use email signatures? Including social media icons in your email signature is a great way to get fans for free. Let all your email users know you’re on social media quickly and easily, in a single click.

Join & Write a Comment

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
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…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

746 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

10 Experts available now in Live!

Get 1:1 Help Now