pywinrm
pywinrm copied to clipboard
Got WinRMOperationTimeoutError when using python winrm library to call a local powershell script on a windows server
I am trying to user winrm library to call a local powershell script to stop MS SQL server engine service from a Lambda function. I got the below error. The connection was established successfully.
The log for establishing connection:
Establishing connection to 10.251.3.22
Connection established
The error I got after the above two logs.
[ERROR] WinRMOperationTimeoutError
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 237, in lambda_handler
result = session.run_ps('c:\shutdown_script.ps1')
File "/var/task/winrm/__init__.py", line 52, in run_ps
rs = self.run_cmd('powershell -encodedcommand {0}'.format(encoded_ps))
File "/var/task/winrm/__init__.py", line 39, in run_cmd
shell_id = self.protocol.open_shell()
File "/var/task/winrm/protocol.py", line 166, in open_shell
res = self.send_message(xmltodict.unparse(req))
File "/var/task/winrm/protocol.py", line 265, in send_message
raise WinRMOperationTimeoutError()
Anyone can help me with troubleshoot this error. I have been stuck in here for over one month. Any help will be great appreciated.
You will have to look at the Windows host event logs to find out why it's not returning the shell creation response. For some reason it's just blocking until the operation timeout is just doing nothing causing the timeout.