开启winrm
winrm quickconfig -q
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'放行防火墙
$allowedIP = "192.168.1.100" # 替换为允许访问的IP地址
New-NetFirewallRule -DisplayName "Windows Remote Management (HTTP-In) from $allowedIP" -Direction Inbound -LocalPort 5985 -Protocol TCP -Action Allow -RemoteAddress $allowedIP
New-NetFirewallRule -DisplayName "Windows Remote Management (HTTPS-In) from $allowedIP" -Direction Inbound -LocalPort 5986 -Protocol TCP -Action Allow -RemoteAddress $allowedIP安装python和pywinrm模块