日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

使用 Powershell 远程连接 windows server

發布時間:2023/12/4 windows 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用 Powershell 远程连接 windows server 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


使用 Powershell 遠程連接 windows server

Intro

最近我們的開發環境增加了一個 windows 服務器,沒有界面的,不能直接遠程桌面連上去管理,需要使用 Powershell 管理,于是就有了這篇文章的探索。

windows服務器配置

以下所有命令需要在管理員賬戶下執行,請以管理員身份運行下面的命令。

  • 在遠程 windows服務器上啟用 powershell 遠程會話:

  • Enable-PSRemoting -Force

  • 配置 TrustedHosts

  • winrm set winrm/config/client '@{TrustedHosts="<your local ip>"}'

  • # winrm set winrm/config/client '@{TrustedHosts="58.123.45.26,134.86.23.21"}' #多個地址用英文的逗號分隔

  • 配置好之后需要重啟一下服務:

  • Restart-Service WinRM

  • 防火墻開放 5985 端口

  • winrm 有兩個端口號,你可以用 winrmgetwinrm/config/client 命令來查看 winrm client 相關配置信息,

    可以看到默認的兩個端口

    • http:5985

    • https:5986

    我們只用了 http 所以開放 5985 端口

    本地配置

  • 配置 TrustedHosts

  • winrm set winrm/config/client '@{TrustedHosts="<remote server ip or host>"}'

  • # winrm set winrm/config/client '@{TrustedHosts="58.123.45.26,134.86.23.21"}' #多個地址用英文的逗號分隔

  • 連接遠程服務器

  • Enter-PSSession -ComputerName <remoteIp or host> -Credential <username>

  • 連接之后,會提示輸入對應用戶的密碼,提交之后就會進行身份驗證

    出現如下圖所示的提示就說明連接成功了,在執行命令就相當于是在遠程windows服務器上執行命令了,就相當于是 SSH 到了 linux 服務器上了

    疑難解答

  • ACCESS IS DENIED

  • 如果你的用戶名密碼都是正確的,但是還是一直提示 ACCESS IS DENIED,那么你需要檢查一下這個用戶是否有 Remote 的權限,遠程的用戶至少要有 Remote 的權限,把用戶加入到 RemoteDesktopUsers 這個用戶組中就會有Remote 的權限

    更多問題請參考: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/aboutremotetroubleshooting?view=powershell-6

    Reference

    • https://www.faqforge.com/windows/create-powershell-session-remote-computer/

    • https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/aboutremotetroubleshooting?view=powershell-6

    • https://docs.microsoft.com/en-us/windows-server/administration/server-manager/server-manager

    • https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/enter-pssession?view=powershell-6

    • https://www.itprotoday.com/windows-78/how-remotely-manage-windows-server-2016


    創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

    總結

    以上是生活随笔為你收集整理的使用 Powershell 远程连接 windows server的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。