EXEXML Sensor returns PE231. I am trying to use a custom powershell script to return useful information on DAG status. The script runs fine when manually executed but I get the aforementioned error. Any advice appreciated. have checked a similar thread but that fix didn't seem to work for me. Here's the script below:
#[CmdletBinding()] #Param( # [Parameter()] # [switch]$Active, # [Parameter(Mandatory=$True)] # [string]$MBServer, # [Parameter(Mandatory=$True)] # [string]$MBDatabase #) $Active = $args[0] $MBServer = $args[1] $MBDatabase = $args[2] Function LoadExchangeSnapin { if (! (Get-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:SilentlyContinue) ) { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 } } Function StatusValue($CopyStatus) { If ($Active) { Switch ($CopyStatus) { "Mounted" {2} "Healthy" {1} default {0} } } Else { Switch ($CopyStatus) { "Healthy" {2} "Mounted" {1} default {0} } } } LoadExchangeSnapin Write-Host "<?xml version=`"1.0`" encoding=`"Windows-1252`" ?>" Write-Host "<prtg>" $Databases = Get-MailboxDatabaseCopyStatus -Server $MBServer ForEach ($Database in $Databases) { if ($MBDatabase -contains $Database.name) { $a = $Database.Status $b = $Database.CopyQueueLength $c = $Database.ReplayQueueLength $d = $Database.ContentIndexState $status = StatusValue($a) Write-Host "<result>" Write-Host "<channel>Status</channel>" Write-Host "<unit>Status</unit>" Write-Host "<mode>Absolute</mode>" Write-Host "<showChart>1</showChart>" Write-Host "<showTable>1</showTable>" Write-Host "<warning>0</warning>" Write-Host "<float>0</float>" Write-Host "<value>$status</value>" Write-Host "<LimitMinWarning>1</LimitMinWarning>" Write-Host "<LimitWarningMsg>Status not Expected</LimitWarningMsg>" Write-Host "<LimitMinError>0</LimitMinError>" Write-Host "<LimitErrorMsg>Status not Expected</LimitErrorMsg>" Write-Host "<LimitMode>1</LimitMode>" Write-Host "</result>" Write-Host "<result>" Write-Host "<channel>Copy Queue Length</channel>" Write-Host "<unit>#</unit>" Write-Host "<mode>Absolute</mode>" Write-Host "<showChart>1</showChart>" Write-Host "<showTable>1</showTable>" Write-Host "<warning>0</warning>" Write-Host "<float>1</float>" Write-Host "<value>$b</value>" Write-Host "</result>" Write-Host "<result>" Write-Host "<channel>Replay Queue Length</channel>" Write-Host "<unit>#</unit>" Write-Host "<mode>Absolute</mode>" Write-Host "<showChart>1</showChart>" Write-Host "<showTable>1</showTable>" Write-Host "<warning>0</warning>" Write-Host "<float>1</float>" Write-Host "<value>$c</value>" Write-Host "</result>" Write-Host "<result>" Write-Host "<channel>Content Index State</channel>" Write-Host "<unit>State</unit>" Write-Host "<mode>Absolute</mode>" Write-Host "<showChart>1</showChart>" Write-Host "<showTable>1</showTable>" Write-Host "<warning>0</warning>" Write-Host "<float>0</float>" if ($d -eq "Healthy") { Write-Host "<value>1</value>" } else { Write-Host "<value>0</value>" } Write-Host "<LimitMinError>0</LimitMinError>" Write-Host "<LimitErrorMsg>Content Index is Not Healthy</LimitErrorMsg>" Write-Host "<LimitMode>1</LimitMode>" Write-Host "</result>" } } Write-Host "</prtg>"
Article Comments
Hi again,
I changed the encoding to UTF-8 but that doesn't help. This is what I see in the log output:
Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.Exchange.Management.Po werShell.E2010' is not installed on this machine. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\Newbase_Ge tDAGStatus-NewTest.ps1:21 char:21 + Add-PSSnapin <<<< Microsoft.Exchange.Management.PowerShell.E2010 + CategoryInfo : InvalidArgument: (Microsoft.Excha...owerShell.E2 010:String) [Add-PSSnapin], PSArgumentException + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.Ad dPSSnapinCommand
<?xml version="1.0" encoding="UTF-8" ?> <prtg> The term 'Get-MailboxDatabaseCopyStatus' is not recognized as the name of a cmd let, function, script file, or operable program. Check the spelling of the name , or if a path was included, verify that the path is correct and try again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\Newbase_Ge tDAGStatus-NewTest.ps1:48 char:43 + $Databases = Get-MailboxDatabaseCopyStatus <<<< -Server $MBServer + CategoryInfo : ObjectNotFound: (Get-MailboxDatabaseCopyStatus:S tring) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
<result> <channel>Status</channel> <unit>Status</unit> <mode>Absolute</mode> <showChart>1</showChart> <showTable>1</showTable> <warning>0</warning> <float>0</float> <value>0</value> <LimitMinWarning>1</LimitMinWarning> <LimitWarningMsg>Status not Expected</LimitWarningMsg> <LimitMinError>0</LimitMinError> <LimitErrorMsg>Status not Expected</LimitErrorMsg> <LimitMode>1</LimitMode> </result> <result> <channel>Copy Queue Length</channel> <unit>#</unit> <mode>Absolute</mode> <showChart>1</showChart> <showTable>1</showTable> <warning>0</warning> <float>1</float> <value></value> </result> <result> <channel>Replay Queue Length</channel> <unit>#</unit> <mode>Absolute</mode> <showChart>1</showChart> <showTable>1</showTable> <warning>0</warning> <float>1</float> <value></value> </result> <result> <channel>Content Index State</channel> <unit>State</unit> <mode>Absolute</mode> <showChart>1</showChart> <showTable>1</showTable> <warning>0</warning> <float>0</float> <value>0</value> <LimitMinError>0</LimitMinError> <LimitErrorMsg>Content Index is Not Healthy</LimitErrorMsg> <LimitMode>1</LimitMode> </result> </prtg>
Jul, 2015 - Permalink
Dear AndreH
According to the log output, the script cannot be fully executed, resulting in an error message as part of the script output. Please check if you run the script using the proper security context. Please check if the sensor is set to use the Windows credentials from the device configuration as security context, and that the device configuration contains proper credentials.
Jul, 2015 - Permalink
Dear AndreH
Please enable "Write result to disk" in the sensor settings to get the sensor input. Are you getting an error message instead of the sensor XML output? If that is the case, please set the sensor to use the Windows credentials from the device configuration as security context. Otherwise the script will run with limited rights.
If that does not help, please try to use UTF-8 encoding instead of Windows-1252.
Jul, 2015 - Permalink