Having trouble with Powershell call to Putty inside HM

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).
mrmichaelbeck
Posts: 30
Joined: Tue Jun 03, 2014 3:35 pm
Location: Edmonton
Contact:

Post by mrmichaelbeck »

powershell.exe %Script% %Params%

I've tried several different locations for the powershell exe. Using the above line gets the same results whether you call powershell from the path variable or from the location in the Windows folder (got it from the properties of the 32bit powershell shortcut).

When I run it manually from powershell's console, I use the one from here: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

Host monitor runs as a service. The option is set toan account called hostmonitor_service. The service runs as hostmonitor_service@imi.ca (@imi.ca is one of our domain names)
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

The issue can be caused by calling defferent powershell versions (32 and 64 bit versions).
Using Start cmd powershell.exe %Script% %Params% in HostMonitor will call 32bit powershell,
while calling %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe from Windows shell will run 64bit powershell.
You may use the following command (in HostMonitor Shell Script test and in powershell console) to check what version of powershell console is used:

Code: Select all

if ([System.IntPtr]::Size -eq 4) { "ScriptRes:Ok:32-bit" } else { "ScriptRes:Ok:64-bit" }
If your script works well in 64bit console, you may tell HostMonitor to use 64bit console by using Start cmd like:
C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe %script% %params%
mrmichaelbeck
Posts: 30
Joined: Tue Jun 03, 2014 3:35 pm
Location: Edmonton
Contact:

Post by mrmichaelbeck »

I will give that a try and let you know. Thanks very much!
mrmichaelbeck
Posts: 30
Joined: Tue Jun 03, 2014 3:35 pm
Location: Edmonton
Contact:

Post by mrmichaelbeck »

Once again, thank you so much for your help. I used the code you supplied and yes, I was running the 64bit while RCC was running the 32bit.

I tried supplying the path you specified for 64bit ...

C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe %Script% %Params%

... and it still returns the no results from plink error. :-) I have also added code in to reverify the path to plink is valid. It still is. I'm not really sure why this is being so difficult.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

What Windows version and service pack do you use? UCA enabled?
Could you try to set Local system account or Built-in Administrator account in HostMonitor Service section (menu Options -> Service) and restart HostMonitor?
Have you tried to test script using "Lets try" option on RCC, running on the same system as HostMonitor?
mrmichaelbeck
Posts: 30
Joined: Tue Jun 03, 2014 3:35 pm
Location: Edmonton
Contact:

Post by mrmichaelbeck »

Hostmonitor runs on a Windows 2008 R2 server. It is not UAC enabled currently.

Unfortunately, if I made the switch to using the local system account or admin account, I may break a number of other tests (we have nearly 1900 tests currently in use). I'm very reluctant to try that.

I'm only able to use the Lets Try option from the HM server. When I try it from my machine, it seems like it's trying to run in the context of my computer rather than the HM server.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Can you use RCC "Lets try" on the same system, where HostMonitor is running, under the same user account that you have tested the script manually?
mrmichaelbeck
Posts: 30
Joined: Tue Jun 03, 2014 3:35 pm
Location: Edmonton
Contact:

Post by mrmichaelbeck »

--> Running as the hostmonitor's service on the hm machine:

[9:04:58 AM] HostMonitor is going to execute "FileCheck" script ...
[9:05:00 AM] Script executed, correct result received:
----------
- Status: Bad
- Reply: No results from call to plink.
----------

--> Running as me on the hm machine (same one as running manually)

[9:08:19 AM] HostMonitor is going to execute "FileCheck" script ...
[9:08:21 AM] Script executed, correct result received:
----------
- Status: Bad
- Reply: No results from call to plink.
----------
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Lets check plink stderr output.
Could you add -batch parameter and 2>c:\temp\stderr.txt to the end of plink command (where c:\temp\stderr.txt - path to error log)?
E.g.:
$results = & $plink -ssh -batch -l $User -pw $pw $IP -m c:\temp\commands.txt 2>c:\temp\stderr.txt

What is content of c:\temp\stderr.txt after running Shell Script test?
mrmichaelbeck
Posts: 30
Joined: Tue Jun 03, 2014 3:35 pm
Location: Edmonton
Contact:

Post by mrmichaelbeck »

That was a good idea. It looks like plink isn't resolving the name of the server that I'm trying to get it to connect to. Thank you for your help!
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Does it work with IP?
mrmichaelbeck
Posts: 30
Joined: Tue Jun 03, 2014 3:35 pm
Location: Edmonton
Contact:

Post by mrmichaelbeck »

I'm getting this now when I use an IP:

[8:13:18 AM] HostMonitor is going to execute "FileCheck" script ...
[8:13:19 AM] Script started, no results received

... so I guess I must have missed a case to handle.
mrmichaelbeck
Posts: 30
Joined: Tue Jun 03, 2014 3:35 pm
Location: Edmonton
Contact:

Post by mrmichaelbeck »

Ok, got that straightened out. It's now calling correctly again... stderr.txt contains...

plink.exe : Unable to read from standard input: The handle is invalid.
At C:\Users\mbeck\AppData\Local\Temp\4\TMP-77~1.PS1:383 char:15
+ $results = & <<<< "$plink" -ssh -batch -l $ASAUser -pw $ASApw $ASAIP
-m c:\temp\commands.txt 2>c:\temp\stderr.txt
+ CategoryInfo : NotSpecified: (Unable to read ...dle is invalid.
:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError



Since I'm running on the HM server as me, that's probably why it's dumping to that temp folder. Do you think maybe there is a permissions issue or something?
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

May we see 383 line of your script where you are calling plink?
mrmichaelbeck
Posts: 30
Joined: Tue Jun 03, 2014 3:35 pm
Location: Edmonton
Contact:

Post by mrmichaelbeck »

Of course...

$results = & "$plink" -ssh -batch -l $ASAUser -pw $ASApw $ASAIP -m c:\temp\commands.txt 2>c:\temp\stderr.txt
Post Reply