如何启用Powershell Remoting PSRemoting或WinRM?

Linux operating systems provide GUI or command line access from its first days. But Windows operating systems are generally managed with only GUI which is generally Remote Desktop. The changes in IT made mass management or orchestration a must for system administrators. Windows have created Powershell for detailed and efficient command line shell and tools. In order to use Powershell remotely we need to enable PSRemoting in target systems. Without enabling it we can not use powershell remote commands like  Invoke-Command .

Linux操作系统从开始就提供GUI或命令行访问。 但是Windows操作系统通常仅使用GUI(通常是远程桌面)进行管理。 IT方面的变化使系统管理员必须进行大规模管理或编排。 Windows已创建Powershell,用于提供详细而有效的命令行Shell和工具。 为了远程使用Powershell,我们需要在目标系统中启用PSRemoting。 如果不启用它,我们将无法使用Powershell远程命令,例如Invoke-Command

客户端出现错误 (Error Appeared In Client)

We may get an error in a red ink like below in the client side powershell. This generally means that remote system do not configured to accept Powershell remote access.

如下图所示,我们可能会在客户端Powershell中出现红色墨水错误。 通常,这意味着远程系统未配置为接受Powershell远程访问。

 + CategoryInfo : OpenError: (:) [], PSRemotingTransportException
 + FullyQualifiedErrorId : PSSessionStateBroken
PSRemotingTransportException
PSRemotingTransportException
PSRemotingTransportException

检查PSRemoting的状态 (Check Status of PSRemoting)

Another way to check whether PS remoting is enabled is running following command in the remote system.

检查PS远程处理是否已启用的另一种方法是在远程系统中运行以下命令。

PS> Get-PSSessionConfiguration
Check Status of PSRemoting
Check Status of PSRemoting
检查PSRemoting的状态

As we can see there is detailed configuration about PSRemoting. This configuration is done according to Powershell version and user types.

我们可以看到有关于PSRemoting的详细配置。 此配置根据Powershell版本和用户类型完成。

启用PSRemoting (Enable PSRemoting)

Now most important part. We will enable the PSRemoting in order to able to run Remote commands using PSRemoting. We will use following command with -force option to prevent some warnings.

现在最重要的部分。 我们将启用PSRemoting,以便能够使用PSRemoting运行远程命令。 我们将使用带有-force选项的以下命令来防止某些警告。

PS> Enable-PSRemoting -Force
Enable PSRemoting
Enable PSRemoting
启用PSRemoting

We can again check like in previous step the status of the PSRemoting.

我们可以像上一步一样再次检查PSRemoting的状态。

将客户端主机添加到受信任的主机 (Add Client Host To The Trusted Hosts)

If previous steps do not works try following command by changing IP address with the remote system.

如果前面的步骤不起作用,请尝试通过更改远程系统的IP地址来执行以下命令。

PS> winrm s winrm/config/client '@{TrustedHosts="192.168.122.167"}'
LEARN MORE  Introduction To Ansible
了解更多Ansible简介

翻译自: https://www.poftut.com/enable-powershell-remoting-psremoting-winrm/

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值