This is more of a dumb question than an issue. I want to be able to set a maximum timeout for a PS command to execute in. For example, if the command I execute is "Start-Sleep 900" I want to say "wait a maximum of 60 seconds".
I was able to do this with pyWinRM by sub-classing Protocol. So the problem in replacing pyWinRM is making sure pypsrp does everything I could do before... This (command execution timeout) and setting IdleTimeout are the only things I am missing.
transport = powershell_pypsrp_transport(PARAMS["server"])
transport.connect(PARAMS)
start_time = time.time()
print("Executing command with command length: {}...".format(len(PARAMS["cmd"])))
transport.run_powershell(PARAMS["cmd"])
end_time = time.time()
if transport.had_errors:
print("Errors returned from command: {}".format(transport.stderr))
else:
print("Results:\n\n{0}\n".format(transport.stdout))
print("Command executed in {} seconds\n".format(int(end_time - start_time)))
But whilst I see that for Shell thre is idle_time_out and lifetime (would lifetime do what I want???) I cannot see how to actually use them in the above code.
This is more of a dumb question than an issue. I want to be able to set a maximum timeout for a PS command to execute in. For example, if the command I execute is "Start-Sleep 900" I want to say "wait a maximum of 60 seconds".
I was able to do this with pyWinRM by sub-classing Protocol. So the problem in replacing pyWinRM is making sure pypsrp does everything I could do before... This (command execution timeout) and setting IdleTimeout are the only things I am missing.
This very basic code works fine:
Using:
But whilst I see that for Shell thre is idle_time_out and lifetime (would lifetime do what I want???) I cannot see how to actually use them in the above code.