Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- from __future__ import print_function
- from winrm.protocol import Protocol
- import sys
- CODEPAGE_UTF8 = 65001
- p = Protocol(
- endpoint='http://{}:5985/wsman'.format(sys.argv[1]),
- transport='plaintext',
- username='CiAdmin',
- password='Passw0rd')
- shell_id = p.open_shell(codepage=CODEPAGE_UTF8)
- command_id = p.run_command(shell_id, sys.argv[2], [])
- ok = False
- try:
- std_out, std_err, status_code = p.get_command_output(shell_id, command_id)
- ok = True
- except KeyboardInterrupt:
- print("Kill ")
- p.cleanup_command(shell_id, command_id)
- p.close_shell(shell_id)
- if ok:
- print("Stdout :", std_out)
- print("Stderr :",std_err)
- print("Statuscode :",status_code)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement