PowerShell execution issue

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
bmekler
Posts: 38
Joined: Tue Apr 17, 2012 4:51 am

PowerShell execution issue

Post by bmekler »

HostMonitor 9.18 on Windows Server 2008 R2, RMA 4.48 on Windows Server 2008 R2 running as service with domain admin credentials, execution policy set to unrestricted for both x64 and x86 powershell.

I'm trying to run the following script to monitor the state of Windows Server backup:

Code: Select all

$statusAlive       = "ScriptRes:Host is alive:"
$statusDead        = "ScriptRes:No answer:"
$statusUnknown     = "ScriptRes:Unknown:"
$statusNotResolved = "ScriptRes:Unknown host:"
$statusOk          = "ScriptRes:Ok:"
$statusBad         = "ScriptRes:Bad:"
$statusBadContents = "ScriptRes:Bad contents:"

if (!$args[0]) 
{
  echo  $statusUnknown"Threshold parameter is not specified" 
  exit
}

$TargetSystem = $args[0]
$DaysToLook = $args[1] * 86400000
$JobCount = 0

$JobCount = (get-winevent -ComputerName "$TargetSystem" -LogName "Microsoft-Windows-Backup" -FilterXPath "*[System[TimeCreated[timediff(@SystemTime) <= $daystolook]]]" | where {$_.id -eq 4}).count

if ($JobCount -gt 0) 
{
   echo $statusOk
} 
else 
{
   echo $statusBad
}
When I save it to a local .ps1 file and run it, either from powershell, or from cmd using powershell.exe with parameters, it runs fine. However, when RMA runs it, I get the following:

[17:54:19] Agent: X is going to execute "PowerShell: Windows Server Backup check" script ...
[17:54:20] Script started, invalid result received:
----------
ÿþS

The "ÿþ" is actually displayed as a square in HostMonitor/RCC UI.

Restarting the agent service or rebooting the server does not help. I have two RMAs installed on two servers in the same network (primary and backup), and the problem occurs on both. However, I haven't run into this issue on any other network yet.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Could you please check [Misc] section of rma.ini file ?
Is there option like SScript_UseWindowsPipe=0 ?
bmekler
Posts: 38
Joined: Tue Apr 17, 2012 4:51 am

Post by bmekler »

Yes there is, precisely that.

Edit: I set it to 1, restarted the RMA and now it's working.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

This means, that Windows Pipes mechanism is not used by RMA.
By default HostMonitor/RMA should use Windows Pipes.
However you disabled it for some reason.
You may enable it by setting value 1, like:
SScript_UseWindowsPipe=1
and restart RMA agent !
However, you should check if other shell script test items work well on this RMA agent with enabled Windows Pipes.
bmekler
Posts: 38
Joined: Tue Apr 17, 2012 4:51 am

Post by bmekler »

Oh, now I remember - you suggested modifying this value here, and I forgot all about it.
Post Reply