*此次是實戰使用于WMF3.0以上版本
一、理論原理
使用PowerShell遠端管理Windows Server是Windows Management Framework的核心思想:使用Powershell充當遠端用戶端,使用WinRM作為接收的服務端,來對遠端的Windows Server進行遠端操作;實驗圖如下:
<a href="http://281816327.blog.51cto.com/attachment/201404/17/907015_1397718421tAcf.png" target="_blank"></a>
二、操作準備
三、實戰
1.在“iis01-op”上開啟Windows Server的WinRM監聽;
<a href="http://281816327.blog.51cto.com/attachment/201404/17/907015_13977184252lX6.png" target="_blank"></a>
2.從iis02_op遠端到iis01-op;
A.在iis02_op的powershell中輸入“enter-pssession –computer iis01-op –credential contoso.test\adminstrator”,然後回車,彈出的對話框中輸入contoso.test\adminstrator的密碼;
<a href="http://281816327.blog.51cto.com/attachment/201404/17/907015_1397718432P3lP.png" target="_blank"></a>
B.點選''OK”後,可以看到我們已經遠端到iis01-op的powershell上;
<a href="http://281816327.blog.51cto.com/attachment/201404/17/907015_1397718433S6yk.png" target="_blank"></a>
3.遠端操作“Ipconfig”事例;
A.在iis01-op上輸入ipconfig,可以看到IP為192.168.11.53;
<a href="http://281816327.blog.51cto.com/attachment/201404/17/907015_1397718434FAaT.png" target="_blank"></a>
B.在iis02_op上遠端到iis01-op的powershell會話中輸入ipconfig,得到同樣的IP位址192.168.11.53;
<a href="http://281816327.blog.51cto.com/attachment/201404/17/907015_1397718435AyLj.png" target="_blank"></a>
4.退出遠端操作;
A.在用戶端退出;在iis02_op遠端的powershell中輸入“enter-pssesion”,即退出遠端會話;
<a href="http://281816327.blog.51cto.com/attachment/201404/17/907015_1397718438SBhW.png" target="_blank"></a>
B.在服務端退出;在iis01-op的powershell中輸入“get-process –name *wsmpro* |stop-process”将關閉所有進入到iis01-op上的遠端會話;
<a href="http://281816327.blog.51cto.com/attachment/201404/17/907015_13977184423wQ7.png" target="_blank"></a>
本文轉自 bannerpei 51CTO部落格,原文連結:http://blog.51cto.com/281816327/1397239,如需轉載請自行聯系原作者