winrm:Windows远程管理
先确定被控机器开启winrm服务
打开powershell命令行
winrm enumerate winrm
快速配置winrm
winrm quickconfig
需要加域
配置winrm
winrm set winrm/config/service/auth @{Basic="true"}
winrm set winrm/config/service @{AllowUnencrypted="true"}
python连接
安装pywinrm
pip install pywinrm
使用pywinrm操作远程服务器
import winrm
def cmd(hotsip="", username="", password=""):
s = winrm.Session(hotsip, auth=(username, password), transport="ntlm")
r = s.run_cmd("ipconfig")
print(r)
cmd("ip", "username", "password")
hotsip:根据官网说明,pywinrm会根据hostip内容推测详细地址,默认情况用5985端口只输入ip即可连接
transport:连接方式,需要指定。比如使用ntlm用户名密码需指定ntlm模式
标签:username,pywinrm,python,winrm,hotsip,Windows From: https://www.cnblogs.com/DarkRoger/p/17817292.html