Having trouble with Powershell call to Putty inside HM
-
- Posts: 30
- Joined: Tue Jun 03, 2014 3:35 pm
- Location: Edmonton
- Contact:
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)
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)
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
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:
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%
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" }
C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe %script% %params%
-
- Posts: 30
- Joined: Tue Jun 03, 2014 3:35 pm
- Location: Edmonton
- Contact:
-
- Posts: 30
- Joined: Tue Jun 03, 2014 3:35 pm
- Location: Edmonton
- Contact:
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.
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.

-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
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?
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?
-
- Posts: 30
- Joined: Tue Jun 03, 2014 3:35 pm
- Location: Edmonton
- Contact:
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.
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.
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
-
- Posts: 30
- Joined: Tue Jun 03, 2014 3:35 pm
- Location: Edmonton
- Contact:
--> 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.
----------
[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.
----------
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
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?
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?
-
- Posts: 30
- Joined: Tue Jun 03, 2014 3:35 pm
- Location: Edmonton
- Contact:
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
-
- Posts: 30
- Joined: Tue Jun 03, 2014 3:35 pm
- Location: Edmonton
- Contact:
-
- Posts: 30
- Joined: Tue Jun 03, 2014 3:35 pm
- Location: Edmonton
- Contact:
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?
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?
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
-
- Posts: 30
- Joined: Tue Jun 03, 2014 3:35 pm
- Location: Edmonton
- Contact: