我正在使用linux python winrm模块在远程windows机器上使用“run_ps”从linux机器运行powershell脚本。在
对于较小的脚本,它可以正常工作,但如果传递太长的powershell代码,则无法执行。在
“run_ps”方法有以下代码。在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
我想可能是“utf_16_le”编码问题或字节大小问题,但不确定。我试过使用“utf_32_le”,但没有结果。在
我使用python2.6.6运行CentOS版本6.2(Final)中的脚本。在