zoukankan      html  css  js  c++  java
  • Powershell Session

    服务器上WinRM服务默认是开启的,

    查看服务是否开启,服务监听5985

    Get-Service winrm*
    

    如果没有开启,使用一下指令开启。

    Enable-PSRemoting -Force
    

    在用户端连接服务器,

    -Credential 可以使用域账号或本地的administrator,其他本地账号要添加到Remote Management Users组里才能连接。

    New-PSSession -ComputerName 主机名或IP   -Credential "domainuser"
    

    报错

    连接到远程服务器失败,错误消息如下: WinRM 客户端无法处理该请求。如果身份验证方案与 Kerberos 不同,或者
    客户端计算机未加入到域中, 则必须使用 HTTPS 传输或者必须将目标计算机添加到 TrustedHosts 配置设置。 使用 winrm.cmd 配置
    TrustedHosts。请注意,TrustedHosts 列表中的计算机可能未经过身份验证。 通过运行以下命令可获得有关此内容的更多信息: winrm
    help config。 有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。
    + CategoryInfo          : OpenError: (:) [], PSRemotingTransportException
    + FullyQualifiedErrorId : PSSessionStateBroken
    

    先启动客户端的winrm,然后将服务器IP添加到客户端的信任列表,重新建立会话即可。

     Start-Service winrm
     Set-Item wsman:localhostclient	rustedhosts *
    

    查看本地建立的会话

    Get-PSSession
    

    进入会话,根据会话ID

    Enter-PSSession 3
    
  • 相关阅读:
    时间计算
    DateTime
    C# trim split dataGrid
    something
    生活
    如何导入外部的源码到eclipse中
    java类中获取ServletContext的方法
    获取spring容器上下文(webApplicationContext)的几种方法
    java反射(转)
    mysql常见命令
  • 原文地址:https://www.cnblogs.com/JinweiChang/p/14718742.html
Copyright © 2011-2022 走看看