发布时间:2019-09-11 07:42:51编辑:auto阅读(3989)
使用session方法
###
import winrm
s=winrm.Session('http://10.10.60.14:5985/wsman',auth=('administrator','password'))
r=s.run_ps('dir')
r=s.run_cmd('cd /d d: & test.bat')
print r.std_out
print r.std_err使用Protocol方法
### import winrm conn = winrm.Protocol(endpoint='http://10.10.60.14:5985/wsman', transport='plaintext', username='administrator', password='password') shell_id=conn.open_shell() com=conn.run_command(shell_id,"dir") stdout, stderr, return_code = conn.get_command_output(shell_id, com) print "STDOUT: %s" % (stdout) print "STDERR: %s" % (stderr)
上一篇: python 文件操作读、写、追加的区别
下一篇: Python的lambda表达式
51336
50790
41383
38186
32675
29570
28407
23284
23248
21575
1655°
2384°
1990°
1930°
2259°
1963°
2659°
4460°
4287°
3058°