winServer-經常使用winrm命令

學習WinServer必須學習powershell,學習powershell必須掌握遠程管理服務器的方法,因此必須學會winrm來遠程管理服務器

記錄一些經常使用的winrm命令和錯誤

經常使用命令

//在Powershell中執行
Set-Item WSMan:\localhost\client\TrustedHosts –Value  "win-2ickeabl4tr.test.com"   -force 
//在Powershell中執行   
Set-Item wsman:\localhost\client\trustedhosts *  
//在Cmd中執行                                             
winrm set winrm/config/client @{TrustedHosts="RemoteComputerName"}  
//在Cmd中執行                      
winrm set winrm/config/client @{TrustedHosts="win-2ickeabl4tr"}  
//在powershell中執行                             
Enter-PSSession 10.10.2.11 -Credential test\administrator
//在powershell中執行                                     
Enter-PSSession win-2ickeabl4tr.test.com -Credential administrator

錯誤1:

{"鏈接到遠程服務器 win-2ickeabl4tr.test.com 失敗,並顯示如下錯誤消息: WinRM 沒法處理該請求。使用 Kerberos 身份驗證時發生錯誤代碼爲 0x80090311 的如下錯誤: 目前沒有可用的登陸服務器,沒法處理登陸請求。  \r\n 可能的緣由爲:\r\n  -指定的用戶名或密碼無效。\r\n  -未指定身份驗證方法和用戶名時,使用了 Kerberos。\r\n  -Kerberos 接受域用戶名,但不接受本地用戶名。\r\n  -遠程計算機名和端口的服務主體名稱(SPN)不存在。\r\n  -客戶端和遠程計算機位於不一樣的域中,而且兩個域之間沒有信任關係。\r\n 檢查上述問題以後,嘗試如下操做:\r\n  -檢查事件查看器中與身份驗證有關的事件。\r\n  -更改身份驗證方法;將目標計算機添加到 WinRM TrustedHosts 配置設置中或 使用 HTTPS 傳輸。\r\n 請注意,TrustedHosts 列表中的計算機可能未通過身份驗證。\r\n  -有關 WinRM 配置的詳細信息,請運行如下命令: winrm help config。 有關詳細信息,請參閱 about_Remote_Troubleshooting 幫助主題。"}

服務器端配置winrm命令

//快速在服務端運行winrm
c:\> winrm quickconfig                  

//查看winrm的運行狀況
c:\> winrm e winrm/config/listener      

//查看winrm的配置
c:\> winrm get winrm/config           

// 將service中的allowUnencrypted設置爲true,容許未加密的通信
c:\> winrm set winrm/config/service @{AllowUnencrypted="true"}    

//將client中的基自己份驗證設置爲true,容許
c:\> winrm set winrm/config/client/auth @{Basic="true"}           

// 將client中的allowUnencrypted設置爲true,容許未加密的通信
c:\> winrm set winrm/config/client @{AllowUnencrypted="true"}    

// 設置主機信任的客戶端地址,這裏host1,2,3能夠填你所在的客戶端機器的ip或者主機名
c:\> winrm set winrm/config/client @{TrustedHosts="host1, host2, host3"}   

//這個沒嘗試過
c:\> winrm identify -r:http://winrm_server:5985 -auth:basic -u:user_name -p:password -encoding:utf-8
相關文章
相關標籤/搜索