Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Powershell commands issued using Statefull Command Proxy Windows 10 #5

Open
OFSTalis opened this issue Nov 17, 2016 · 6 comments
Labels

Comments

@OFSTalis
Copy link

Node.js version: v4.2.6
Platform: Windows 64 bit
Subsystem: Windows 10 Pro

Hello, I was wondering if you may have an insight into my problem. I have been working on automated testing using Node.js on a Windows 7 machine which issues commands to a virtual machine using Powershell - this works as expected no problems. However, I have now upgraded to Windows 10 (no option to down grade again) and everything works fine except for Powershell commands. I can run commands by manually opening a powershell window, but commands contained within a script using the command proxy do not seem to work. The number of clients just seems to increase and they are never released (made available). I have included below the output from one of my scripts.

I can find no additional information in any windows logs.

Any help would be greatly appreciated

Regards

Talis

Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Started
INFO PSCommandService Executing:
Invoke-eXimiusTestAction -DatabaseName 'QA_Product_56_587_DATA' -DatabaseServer 'BEMECHE1SQL03\SQL2012' -ServiceName 'B-Misc' -MethodName 'BackupRestoreTable' -Parameters '{"BackupRestoreAction":"B","Table":"price","DeleteTableContent":"False"}'

INFO Pool dispense() clients=1 available=0
INFO StatefulProcessCommandProxy create new process: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
INFO ProcessProxy[null] Spawning process: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
INFO ProcessProxy[null] Process: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe PID: 21752
INFO PSCommandService Executing:
Invoke-eXimiusTestAction -DatabaseName 'QA_Product_56_587_DATA' -DatabaseServer 'BEMECHE1SQL03\SQL2012' -ServiceName 'B-Misc' -MethodName 'BackupRestoreTable' -Parameters '{"BackupRestoreAction":"B","Table":"systemparameter","DeleteTableContent":"False"}'

INFO Pool dispense() clients=2 available=0
INFO PSCommandService Executing:
Invoke-eXimiusTestAction -DatabaseName 'QA_Product_56_587_DATA' -DatabaseServer 'BEMECHE1SQL03\SQL2012' -ServiceName 'B-Misc' -MethodName 'ExecuteSQL' -Parameters '{"Query":"update Price set PriceDateTime = ''2016-02-25 00:00:00.000'', PriceAmount_Am = ''6.500000'' where ObjID = ''29501CBB-FBC6-4F71-B244-4E84E54756DB''","QueryHash":"2016-11-14T15:31:48.664Z"}'

INFO Pool dispense() clients=3 available=0
INFO PSCommandService Executing:
Invoke-eXimiusTestAction -DatabaseName 'QA_Product_56_587_DATA' -DatabaseServer 'BEMECHE1SQL03\SQL2012' -ServiceName 'B-Misc' -MethodName 'ExecuteSQL' -Parameters '{"Query":"update Price set PriceDateTime = ''2016-02-25 00:00:00.000'', PricePercentage = ''100.000000000'' where ObjID = ''9FAA78E6-06B5-4EE5-B42F-FD49BC971AEF''","QueryHash":"2016-11-14T15:31:48.665Z"}'

INFO Pool dispense() clients=4 available=0
INFO PSCommandService Executing:
Invoke-eXimiusTestAction -DatabaseName 'QA_Product_56_587_DATA' -DatabaseServer 'BEMECHE1SQL03\SQL2012' -ServiceName 'B-Misc' -MethodName 'SetSystemParameter' -Parameters '{"ParameterName":"PortfolioBalanceDate","ParameterValue":"2016-02-25 00:00:00","TenantAware":"False"}'

INFO Pool dispense() clients=5 available=0

After this, the script hangs until the time out is reached.

@bitsofinfo
Copy link
Owner

I don't see any related errors here. My guess is that there must be a change in the way Windows 10 is handling the powershell commands you are invoking or the initialization commands you run in each shell as it it is spawned. If they are hanging then they are waiting on completion of the commands you are executing. I'd try manually executing everything exactly the same as you have everything configured, including any initialization commands.

@GlennQuirynen
Copy link

Hi,

I've been also been looking into this problem. Working in the same company as Talis.

To give some more background. We are trying to execute commands on a remote machine.
We have created a custom powershell addin, which is able to do that.

To make sure, our problem has nothing to do with the custom addin, I have replaced it with a simple powsershell command "Write-EventLog" action.

'eXimiusWriteEventLogAction': {
'command': 'Write-EventLog {{{arguments}}}',
'arguments': {
'LogName': { 'default': '', 'quoted': true },
'Source': { 'default': '', 'quoted': true },
'EventId': { 'default': '', 'quoted': true },
'Message': { 'default': '', 'quoted': true }
},
'return': { type: 'string' }
}

when running all the commands manually directly in a powershell command window, it all works fine.

We have specified 3 initCommands
FYI, even without the Add-PSSnapin init command, it still does not work.
The last command Write-Eventlog, I added for debug purposes

initCommands: [
'Enter-PSSession -ComputerName ' + process.env.ServerName,
'Add-PSSnapin eXimiusPowerShellSnapIn',
'Write-EventLog -LogName "Application" -Source "eXimius" -EventId 1 -Message "WIN10 REMOTE INIT"'
],

we have 1 preDestroyCommand

preDestroyCommands: ['Exit-PSSession']

The initcommands do go off, as we actually see the message "WIN10 REMOTE INIT" in the eventlog of the remote machine.

But the actual call in the executePowerShell function (which we now for debug changed with the custom WriteEventLog action), hangs and does not do anything.

return psCommandService.execute('eXimiusWriteEventLog', {
'LogName': 'Application',
'Source': 'eXimius',
'EventId': '1',
'Message': 'WIN 10 REMOTE CUSTOM ACTION'
});

I enabled verbose logging, and the only info we see is

INFO PSCommandService Executing:
Write-EventLog -LogName 'Application' -Source 'eXimius' -EventId '1' -Message 'WIN 10 REMOTE CUSTOM ACTION'

INFO Pool dispense() clients=1 available=0
VERBOSE Pool createResource() - creating obj - count=1 min=0 max=1
INFO StatefulProcessCommandProxy create new process: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
INFO ProcessProxy[null] Spawning process: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
INFO ProcessProxy[null] Process: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe PID: 1184
INFO PSCommandService Executing:
Write-EventLog -LogName 'Application' -Source 'eXimius' -EventId '1' -Message 'WIN 10 REMOTE CUSTOM ACTION'

INFO Pool dispense() clients=2 available=0

On a windows 7 machine, where it all is working fine, we see after the POOL message following additional messages.

INFO StatefulProcessCommandProxy new process ready, initialization commands completed.
INFO Pool dispense() clients=1 available=1
INFO Pool dispense() clients=0 available=1

Hope this gives a bit more information in order for you to help us out?

Thanks

@bitsofinfo
Copy link
Owner

bitsofinfo commented Jan 6, 2017

So you are saying that this command is the one that does not work?

Write-EventLog -LogName 'Application' -Source 'eXimius' -EventId '1' -Message 'WIN 10 REMOTE CUSTOM ACTION'

So do you see any evidence of this command being received at the remote machine?

Have you done a tcpdump to see any indication of this command triggering a network operation?

What if you alter the command to make it 2 commands separated by a legit window delimiter (like ; on bash), and have it echo something to a local file. That would give you evidence that the command gets to the shell and is being executed.

Unfortunately I have no access to windows 10 or am familiar at all w/ the tools/cmds you are invoking.

Regardless, please understand that all this does at the core is write a cmd to stdin, and capture stdout/stderr.

If there is a perceived "hang" then something w/ Node on windows 10 and how it interacts w/ process streams may have changed.

@GlennQuirynen
Copy link

Hi,

thanks for the quick reply.

Indeed, we use as showcase to you guys, the Write-Eventlog, to rule out a problem on our addin.

If we directly call the write-eventlog in the init commands, we see a entry in the eventlog of the remote machine.

If we do the same with the main command (which just wraps the write-eventlog).

return psCommandService.execute('eXimiusWriteEventLog', {
'LogName': 'Application',
'Source': 'eXimius',
'EventId': '1',
'Message': 'WIN 10 REMOTE CUSTOM ACTION'
});

It does not work and hangs. And we don't see any event in the eventlog of the remote machine.

I will try the tcpdump and the echo, and keep you updated.

@bitsofinfo
Copy link
Owner

bitsofinfo commented Jan 6, 2017

Ok, yes to really debug this it would be best to widdle it down to the simplest reproducible sample that could be run anywhere with no custom dependencies.

Preferably something that demonstrates the issue, with a non-remote command.

@bitsofinfo
Copy link
Owner

Anyone come up w/ a simple reproducible example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants