What if instead of “wrapping” a service around it the script ran as a scheduled task every 5 minutes?
For the task properties the command line becomes something like C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
And the argument &'C:\Path_To_Client\ XymonPSClient.ps1'
Put a tick in repeat task, set the period to 5 mins and the duration to indefinably. Probably no need to save the password.
The task can be exported as an xml file for import into other systems and/or included in the distribution package.
Regards Graeme
From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of David Baldwin Sent: Wednesday, 13 November 2013 3:55 PM To: Jason Richards Pagh; xymon at xymon.com Subject: [Xymon] Re: WinPSClient - Updates?
Jason,
Thanks for the email. So it looks like the WinPSClient hasn’t been updated in a few months. I had seen a thread from quite a while ago about some issues David was running into, but can’t tell if he’s still around and willing/able to work on it.
In principle I am interested, but don't have a lot of time to work on it at present.
I’ve been able to get XymonPSClient.exe (aka SrvAny) to run powershell natively as a 64-bit executable. The only change necessary to enable this was changing the PowerShell executable to running as %windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe. The sysnative portion prevents a 32-bit program (SrvAny) from being redirected to %windir%\SysWow64. (See http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx<http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187%28v=vs.85%29.aspx>).
Thanks - I found the "sysNative" workaround a month or two ago also. Very useful for running PS scripts from BBWin since it is still 32-bit only.
I also found a better service wrapper than SrvAny, namely nssm (http://nssm.cc/). This has the ability to detect if powershell fails and restart it, which is something SrvAny lacks. It also comes in both 32-bit and 64-bit versions, so when using the latter the sysnative piece isn’t necessary. I’ve only been working at this for a day or two, so it probably needs more testing, but it looks promising.
That's an awesome improvement. Definitely a big advance :)
Is there any work (design contemplation) about how xymonclient.ps1 could handle external scripts? I assume this was just a future phase and not so much a limitation or barrier that hadn’t yet been overcome.
I'd played around with things like start-job in PS, but I hadn't worked through all of the legacy reporting mechanisms from BBNT/BBWin (e.g. writing text files into directory - that's an easy one in practice) but more to the point worked out throttling mechanisms for long-running scripts that don't exit, etc. Had also considered just running external scripts as scheduled tasks, but not had time to investigate.