zoukankan      html  css  js  c++  java
  • 使用HTTP方式远程连接PowerShell

    借助Windows PowerShell,我们可以像管理Linux一样使用命令行来远程管理Windows服务器。但是默认情况下,我们只能在域环境中使用PowerShell Remoting。如果是通过互联网远程连接到Windows服务器,则必须使用SSL(HTTPS)——这就意味着必须在远程服务器和客户端上配置证书,真心麻烦。虽然这些手段都是为了安全考虑,不过也确实给用户带来诸多不便。

    其实,PowerShell Remoting是支持HTTP协议的(完全不需要配置证书):

    首先在服务器上开启TCP 5985端口(操作系统防火墙和外部防火墙都要允许这个端口通过),这是PowerShell Remoting HTTP模式下使用的端口。

    然后在服务器上以管理员身份运行PowerShell,执行以下命令:

    #开启远程管理并跳过网络检查
    Enable-PSRemoting -SkipNetworkProfileCheck -Force

    #设置信任主机,允许所有客户端管理本服务器
    Set-Item WSMan:localhostClientTrustedHosts -Value "*" -Force

    在客户端上以管理员身份运行PowerShell,运行以下命令:

    Set-Item WSMan:localhostClientTrustedHosts -Value "*" -Force

    经过上述步骤,就可以连接到远程的Windows服务器执行Powershell操作啦。

    $cred = Get-Credential
    Enter-PSSession -ComputerName 服务器IP地址 -Credential $cred
  • 相关阅读:
    Windows快捷键
    visual studio code颜色主题切换
    visual studio code中文语言包安装
    顶点缓存与索引缓存
    程序结构(2)
    ansible常用模块
    ansible常用模块
    ubuntu实用技巧
    ubuntu实用技巧
    Sqoop导出MySQL数据
  • 原文地址:https://www.cnblogs.com/hunterxue/p/5319317.html
Copyright © 2011-2022 走看看