I am trying to get the below script working to monitor the DAG Replication in our Exchange 2010 environment, but it keeps erroring out with a 'the specified module can not be found' error.
First the environment...
Exchange Servers: Exchange 2010 SP2 RU4 on Server 2008 R2 x64
Orion Remote Poller: SAM 5.0.1.2040 on Server 2008 R2 x64, EMC 2010 SP2 RU4 installed.
Credential for Monitoring: Domain account with Local Admin rights Exchange Servers and Orion Servers, and member of Exchagne 'View-Only Organization Management' group.
The script in question...
$ErrorActionPreference = "silentlycontinue";
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010;
$hostname = $null
$ipaddress = "${IP}"
$message = $null
$stat = 0
$hostname = [System.Net.Dns]::GetHostbyAddress($ipaddress).HostName;
$Error.Clear();
if ( !$hostname )
{
$message = "Could not resolve hostname";
$stat = 4;
} else {
Test-ReplicationHealth -Identity $hostname -TransientEventSuppressionWindow 2 | ForEach {
If ( $stat -eq 0 ) { $message = "Replication is Healthy" }
If ( $_.Result -notmatch "Passed" ) {
$message = "$($_.Check) Error: $($_.Error)";
$stat = 3;
}
}
}
if ( $Error.Count -ne 0 )
{
$message = "$($Error[0])";
$stat = 1;
}
Write-Host "Message: $message";
Write-Host "Statistic: $stat";
Exit $stat;
I can run this script from the remote poller computer while logged in as the same user used for monitoring in SAM and everything works as expected. The script returns with 'Message: Replication is Healthy" and an exit code of 0.
When I attempt to run this script from within SAM it returns with...
Testing on node 'x.x.x.x' failed with 'Down' status ('Down' might be different if script exits with a different exit code).
The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Output: ==============================================
Message: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Statistic: 1
The template I am using for this component is setup as follows...
Platform to run polling job on: 64bit
Component type: Windows Powershell Monitor
Credential for monitoring: SamMonitor < tested and working account for other exchange powershell monitors
Execution Mode: Local Host
Run the script under specified account: checked
I have tracked the error down to being the 'Test-ReplicationHealth' command being the culprit, but cannot figure out why it would work from the console, but not from within Orion. Can anyone offer some thoughts and perhaps point me in the right direction?