Windows开启WinRM

  1. 新建powershell脚本
  2. 执行开启winrm
  3. 验证

新建powershell脚本

这里的powershell脚本配合阿里云批量分发执行,比较方便,可以批量配置windows server
桌面新建文本,内容以下:

# powershell.exe -executionpolicy remotesigned -noexit c:\users\jack\desktop\openwinrm.ps1
echo "setp 1..."
set-executionpolicy remotesigned
echo "setp 2..."
winrm quickconfig
echo "setp 3..."
winrm set winrm/config/service/auth '@{Basic="true"}'
echo "setp 4..."
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
$now = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
"[{0}][{1}] Success ...." -f $now,$pid
Exit 0

保存后,修改文件名为openwinrm.ps1

执行开启winrm

# powershell.exe -executionpolicy remotesigned -noexit c:\users\jack\desktop\openwinrm.ps1

验证

curl -vk -d " " -u "jack:password" https://192.168.1.206:5986/wsman

ansible -i hosts 192.168.1.206 -m win_ping

转载请注明来源, 欢迎对文章中的引用来源进行考证, 欢迎指出任何有错误或不够清晰的表达, 可以邮件至 chinaops666@gmail.com
相册