I have some APM monitors setup with the below modified VBScript:
'----------------------------------------------------------------------
'
' Name: PowerShell x64 Process Launcher
' Designed specifically for use with
' Tested Environment: Windows 2008 R2 SP1
' Solarwinds Orion APM 4.0.2
' Author: KMSigma on www.thwack.com;
' Last Update: 2011-04-01
'
'----------------------------------------------------------------------
'
' Parameters: (Ordered)
' 1) File Path to PowerShell Script to Execute
' * If the path includes spaces, surround the entire *
' * parameter with double-quotes *
' * eg. "C:\My Scripts\Script with spaces.ps1" *
' 2) Second and Additional Parameters are those
' which should be passed to the PowerShell Script
' (Optional)
'
'----------------------------------------------------------------------
'Define a few variables first
Dim strPowerShellExecutable, strPowerShellScript, strPowerShellParameters
Dim intOutput, strPowerShellLaunch
' Check on the Number of Parameters - at least the path to the
' PowerShell script needs to be defined.
If Wscript.Arguments.Count = 0 Then
' Return the Error Message
Wscript.echo "Message: Parameter 1 is missing, but required. " & _
"Re-execute with parameter defined as the full file path " & _
"to the PowerShell script to execute in 64-bit mode."
' Return the generic required "Statistic" value
Wscript.echo "Statistic: 0"
' Return Quit with Error 1 - To Indicate Failure
wscript.quit(1)
Else
' Populate the variable to hold the PowerShell Script Path
strPowerShellScript = Wscript.Arguments(0)
' Check to see if there are more arguments
If ( wscript.arguments.Count >= 2 ) Then
' Cycle through the parameters passed to this vbScript and store in an array
For i = 1 to Wscript.Arguments.Count - 1
' "Paste" on each additional parameter
strPowerShellParameters = strPowerShellParameters & " " & Wscript.Arguments(i)
Next
End If
End If
' File Path to the PowerShell Executable
' (This should NOT be modified for Windows 2008 R2)
strPowerShellExecutable = "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"
' Build the completed string for Shell Execution
strPowerShellLaunch = strPowerShellExecutable & " -file " & strPowerShellScript & strPowerShellParameters
' Empty Variables to Free Memory
' (probably unecessary, but good practice)
Set strPowerShellExecutable = Nothing
Set strPowerShellScript = Nothing
Set strPowerShellParameters = Nothing
' Create new Shell Object
Set objShell = CreateObject("Wscript.Shell")
'Assign the Shell Object to execute a powershell script with (optional) parameters from above
Set objStdExec = objShell.Exec(strPowerShellLaunch)
'Close the Standard Input
objStdExec.StdIn.Close()
intOutput = objStdExec.StdOut.ReadAll
wscript.echo intOutput
'Read all the information from the standard output
WScript.Echo "Statistic: "& intOutput
'exit using the same exit code as from powershell
WScript.Quit(intOutput)
An example script argument is C:\scripts\sg01.ps1.
The Powershell script is the following:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
$result = @()
$result = Get-MailboxDatabase -StorageGroup "EX01\SG01" -Status
if ($result.Mounted)
{Write-Host 0}
else
{Write-Host 1}
exit
The script works and gets the correct results. I have a bunch of them look at the Mounted status of each of our Exchange databases and the enabled status of the SMTP connectors. Randomly any one of the monitors will go into an unknown state, then go back to being up. I have Exchange Management Console installed on my Orion server and the app monitor assigned to the Orion server. Any one have any ideas on why this might be occurring? As an FYI, I am scheduled to install APM 4.0.2 this weekend.
Bryan
NPM 10.1.2, APM 4.0.1, IPSLA 3.5.1 NTA 3.7