Solved

Need help with exchange powershell script

Posted on 2010-09-23
7
568 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
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 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…

831 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