Windows 远程管理(WinRM)的配置确实有些让人困惑。经过一番折腾,我终于把这个功能配置成功了。下面是我的配置过程,希望对你有帮助。
服务端
启动 winrm 服务
在 PowerShell 中(以管理员身份):
net start winrm或者在 CMD 中(以管理员身份):
winrm quickconfig注意:如果当前用户不是原始的 "administrator" 账户,请在 CMD(以管理员身份)中运行下面的命令。
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f
在 PowerShell 中查看 winrm 的状态:
Get-Service | findstr "WinRM"启动监听
在 PowerShell 中启用远程管理:
Enable-PSRemoting -Force在 CMD 中用下面的命令查看 winrm 的监听状态:
winrm enumerate winrm/config/listener客户端
启动 winrm 服务
启动 winrm 服务(PowerShell)
net start winrm查看服务状态(PowerShell)
Get-Service | findstr "WinRM"启用远程管理(非必需,可跳过)
启用远程管理(PowerShell)
Enable-PSRemoting -Force把服务器加入信任列表(必需)
把服务器 IP 加入信任列表:
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.1.2"
Get-Item WSMan:\localhost\Client\TrustedHosts连接服务器(如果报错,请指定计算机名)
连接服务器
Enter-PSSession x.x.x.x -Credential $X或者
Enter-PSSession x.x.x.x -Credential yourcomputername\yourusername注意:计算机名很重要,不指定计算机名可能会出现连接错误。
参考
https://serverfault.com/questions/530903/enable-psremoting-on-windows-server-2008-r2-error
0 条评论