I am using linux python winrm module to run powershell scripts from linux machine on remote windows machine using "run_ps".
It is working fine for small size of script but failing to execute if pass too long power shell code.
The "run_ps" method has following code.
def run_ps(self, script):
"""base64 encodes a Powershell script and executes the powershell
encoded script command
"""
# must use utf16 little endian on windows
base64_script = base64.b64encode(script.encode("utf_16_le"))
rs = self.run_cmd("powershell -encodedcommand %s" % (base64_script))
if len(rs.std_err):
# if there was an error message, clean it it up and make it human
# readable
rs.std_err = self.clean_error_msg(rs.std_err)
return rs
I guess it may be "utf_16_le" encoding issue or bytes size issue but not sure. I have tried using "utf_32_le" but no results.
I am running script from CentOS release 6.2 (Final) using Python 2.6.6.
Linux Python Winrm module link: https://github.com/diyan/pywinrm/