import sys, base64, winrm
ip, user, pw = sys.argv[1], sys.argv[2], sys.argv[3]
ps = base64.b64decode(sys.argv[4]).decode()
s = winrm.Session("http://%s:5985/wsman" % ip, auth=(user, pw), transport="ntlm", server_cert_validation="ignore")
r = s.run_ps(ps)
out = r.std_out.decode(errors="ignore"); err = r.std_err.decode(errors="ignore")
print(out[:6000])
if err.strip(): print("[stderr]", err[:600])
