Created
December 11, 2017 04:08
-
-
Save alexhrescale/686fc3909c1400e678141296c8928a7d to your computer and use it in GitHub Desktop.
Winrm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import winrm | |
from winrm.protocol import Protocol | |
HOSTNAME='ec2-aaa-bbb-ccc-ddd.compute-1.amazonaws.com' | |
ENDPOINT='http://%s:5985/wsman' % HOSTNAME | |
USERNAME='Administrator' | |
PASSWORD='blahblah' | |
p = Protocol( | |
endpoint=ENDPOINT, | |
transport='ntlm', | |
username=USERNAME, | |
password=PASSWORD, | |
server_cert_validation='ignore', | |
# message_encryption='auto', # seems unnecessary | |
) | |
shell_id = p.open_shell() | |
command_id = p.run_command(shell_id, 'ipconfig', ['/all']) | |
std_out, std_err, status_code = p.get_command_output(shell_id, command_id) | |
p.cleanup_command(shell_id, command_id) | |
p.close_shell(shell_id) | |
print(std_out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment