MSExchange ,the Exchange Command Management Console with PowerShell can get some infomation such as mailbox statistics ,mail server statistics to monitor the exchange, but these commands can only run at the Exchange Command Management Console .
How can i run these commands like get-mailbox through HM(with rma) for monitoring?
thanks.
Monitor MSExchange with HM
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
You may use Shell Script test method to run MS Exchange Powershell commands.
E.g. You may use the following powershell script with Shell Script test method to check MS Exchange mailbox database state:
Start CMD: powershell.exe %script% %params%
Please check the manual or visit our web site for more information at:
Shell Script test method: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell
E.g. You may use the following powershell script with Shell Script test method to check MS Exchange mailbox database state:
Code: Select all
Add-PSSnapin Microsoft.Exchange.*
$mounted = (Get-MailboxDatabase -Identity $args[0] -status).Mounted
if($mounted)
{echo $statusOk}
else
{echo $statusBad}
Please check the manual or visit our web site for more information at:
Shell Script test method: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell
-
- Posts: 20
- Joined: Sun Aug 02, 2009 7:29 pm
thank you first.
there is a ps1 file, when execute on the remote exchange server , it is ok.
but can't be executed on the HM server by rma.
the ps1 file:
Add-PSSnapin Microsoft.Exchange.*
$HMMailNums1 = Get-MailboxStatistics -Identity archiver | ft -h totalitemsize > c:\test\test.tmp1
$HMMailNums2 = (get-content c:\test\test.tmp1)[1] > c:\test\test.tmp2
$HMMailNums = (get-content c:\test\test.tmp2 -delimiter B)[0]
echo $HMMailNums
the error msg:
[9:54:21] Agent: 172.28.90.2 is going to execute "PowerShell: Get-MailboxStatistics totalitemsize" script ...
[9:54:22] Script started, invalid result received:
----------
?
C
the reply:
Error: Invalid result (C
the startcmd:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe %script% %params%
or
powershell.exe %script% %params%
there is a ps1 file, when execute on the remote exchange server , it is ok.
but can't be executed on the HM server by rma.
the ps1 file:
Add-PSSnapin Microsoft.Exchange.*
$HMMailNums1 = Get-MailboxStatistics -Identity archiver | ft -h totalitemsize > c:\test\test.tmp1
$HMMailNums2 = (get-content c:\test\test.tmp1)[1] > c:\test\test.tmp2
$HMMailNums = (get-content c:\test\test.tmp2 -delimiter B)[0]
echo $HMMailNums
the error msg:
[9:54:21] Agent: 172.28.90.2 is going to execute "PowerShell: Get-MailboxStatistics totalitemsize" script ...
[9:54:22] Script started, invalid result received:
----------
?
C
the reply:
Error: Invalid result (C
the startcmd:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe %script% %params%
or
powershell.exe %script% %params%
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Shell Script test has special script output requirement.
Your script should echo string like
scriptres:Host is alive:1000 ms
or
scriptres:Bad:90 % e.t.c.
With such output HostMonitor is able to recognise test Status and Reply.
You may find Powershell Script sample in HostMonitor Script Manager.
Please check for details at: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell
Also, what HostMonitor and RMA version do you use ?
Your script should echo string like
scriptres:Host is alive:1000 ms
or
scriptres:Bad:90 % e.t.c.
With such output HostMonitor is able to recognise test Status and Reply.
You may find Powershell Script sample in HostMonitor Script Manager.
Please check for details at: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell
Also, what HostMonitor and RMA version do you use ?