felix-cao / Blog

A little progress a day makes you a big success!
31 stars 4 forks source link

Ansible 远程管理 Windows主机 #182

Closed felix-cao closed 4 years ago

felix-cao commented 4 years ago

一、

1.1 Ansible 管理主机

系统: CentOS6.8 IP : 192.168.1.5

1.2 Window 客户机

系统:Windows Server 2019 Essentials(Version: 1809) IP: 192.168.1.7 Windows机器需要安装或升级powershell4.0以上版本, 注意:升级powershell需要重新服务器才能生效。

查看 powershell 版本

$PSVersionTable.PSVersion
# 或
get-host

image

二、Windows客户端配置winrm,启用powershell远程管理

1、执行策略

get-executionpolicy // 查看powershell执行策略
set-executionpolicy remotesigned // 更改powershell执行策略为remotesigned
  1. 配置winrm service并启动服务

    winrm quickconfig

    image

  2. 查看winrm service启动监听状态 winrm enumerate winrm/config/listener

  3. 修改winrm配置,启用远程连接认证 winrm set winrm/config/service/auth '@{Basic="true"}' winrm set winrm/config/service '@{AllowUnencrypted="true"}'

image