Exchange 2007 Database state check

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
42long
Posts: 1
Joined: Thu May 20, 2010 2:54 am

Exchange 2007 Database state check

Post by 42long »

Hi
can someone please tell me if there is a test that i can do to check exchange 2007 database stae (mount or dismount) ?
is there any test that can do this ?
thanks
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

I think you may use Shell Script test method and script like the following

Code: Select all

$statusOk          = "ScriptRes:Ok:"
$statusBad         = "ScriptRes:Bad:"

dd-PSSnapin Microsoft.Exchange.*
$mounted = (Get-MailboxDatabase -Identity $args[0] -status).Mounted
if($mounted) 
{echo  $statusOk}
else
{echo  $statusBad}
Command to start script: powershell.exe %script% %params%
Parameters: just 1 parameter that should specify hostname and database name, e.g. servername\databasename

More information about Shell Script test method
http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell

Regards
Alex
esirignano
Posts: 7
Joined: Tue Mar 23, 2010 11:41 am

Post by esirignano »

I know this topic is old but I am having trouble getting this test to work. Test status returns as bad but I know 100% the info store is mounted.



Params:

MyCompany/Engineering Database




Start cmd:

powershell.exe %script% %params%




Script:

$statusOk = "ScriptRes:Ok:"
$statusBad = "ScriptRes:Bad:"

Add-PSSnapin Microsoft.Exchange.*
$mounted = (Get-MailboxDatabase -Identity $args[0] -status).Mounted
if($mounted)
{echo $statusOk}
else
{echo $statusBad}



Any Ideas? This is running against Exchange 2007.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

How exactly did you set param ?
Parameter like MyCompany/Engineering Database will be interpreted as two "MyCompany/Engineering" and "Database"
You should use quotes for parameter like:
'MyCompany/Engineering Database'
esirignano
Posts: 7
Joined: Tue Mar 23, 2010 11:41 am

Post by esirignano »

I've tried:

MyCompany/Engineering Database
'MyCompany/Engineering Database'
"MyCompany/Engineering Database"

All return the same results.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

1. Please use backslash ( \ ) instead of slash ( / ) for database path, like 'MyCompany\Engineering Database'
2. If ShellScript runs on local server (where Exchange is located) you may try to use just database name like 'Engineering Database'

If Scrip still doesn't work, try the following:
1. Start powershell.exe
2. run command Add-PSSnapin Microsoft.Exchange.*
3. run command Get-MailboxDatabase
4. Can you see your databases after Get-MailboxDatabase was executed ?
5. Do you see any error messages after these commands ?
esirignano
Posts: 7
Joined: Tue Mar 23, 2010 11:41 am

Post by esirignano »

KS-Soft Europe wrote:1. Please use backslash ( \ ) instead of slash ( / ) for database path, like 'MyCompany\Engineering Database'
2. If ShellScript runs on local server (where Exchange is located) you may try to use just database name like 'Engineering Database'

If Scrip still doesn't work, try the following:
1. Start powershell.exe
2. run command Add-PSSnapin Microsoft.Exchange.*
3. run command Get-MailboxDatabase
4. Can you see your databases after Get-MailboxDatabase was executed ?
5. Do you see any error messages after these commands ?

1. I'm sorry, I was originally using a backslash ( \ ).
2. It does run locally, I tried to use just 'Engineering Database', same result.

I can see the databases using your instructions, no errors.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

What HostMonitor version do you use ?
What Windows do you use ? Service Pack ? x86, x64 ?

Also, I noticed mistake in script of second post.
there should be:
Add-PSSnapin Microsoft.Exchange.*
instead of:
dd-PSSnapin Microsoft.Exchange.*

Please check if you are using right command: Add-PSSnapin Microsoft.Exchange.*

Also, you may check if database name is correct using powershell.exe with the following commandlets:
1. Add-PSSnapin Microsoft.Exchange.*
2. Get-MailboxDatabase -Identity 'MyCompany/Engineering Database'
esirignano
Posts: 7
Joined: Tue Mar 23, 2010 11:41 am

Post by esirignano »

8.86
Windows 2008 Server Enterprise x64 Edition Service Pack 2

My script has the correct "Add-PSSnapin Microsoft.Exchange.*". I did notice that error when I first came across this script.


PS C:\Users\administrator> Add-PSSnapin Microsoft.Exchange.*
PS C:\Users\administrator>
PS C:\Users\administrator> Get-MailboxDatabase -Identity 'Engineering Databa
se'

Name Server StorageGroup Recovery
---- ------ ------------ --------
Engineering Database EXCHANGE Engineering Stora... False
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Looks like problem is related to different powershell versions x86 and x64.
You start powershell 64 bit version, while HostMonitor calls 32 bit.

Could you please copy x64 powershell.exe from default location (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe)
to some other location (path should not include word "powershell") E.g. c:\win64tools\powershell.exe
Then specify it in "start CMD" of ShellScript test, like:
c:\win64tools\powershell.exe %Script% %Params%
instead of
powershell.exe %script% %params%

This will make HostMonitor use 64 bit powershell.
esirignano
Posts: 7
Joined: Tue Mar 23, 2010 11:41 am

Post by esirignano »

That did it, it is now working. Really appreciate your help with this issue.

Here are my final test settings.

Params: 'Engineering Database'

Start CMD: C:\SYSTEMTOOLS\powershell.exe %script% %params%

Script:

Code: Select all

$statusOk          = "ScriptRes:Ok:" 
$statusBad         = "ScriptRes:Bad:" 

Add-PSSnapin Microsoft.Exchange.* 
$mounted = (Get-MailboxDatabase -Identity $args[0] -status).Mounted 
if($mounted) 
{echo  $statusOk} 
else 
{echo  $statusBad}
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

That did it, it is now working.
Great :)
Really appreciate your help with this issue.
You are welcome.
Post Reply