
進化:從孤膽極客到高效團隊

In this installation of Geek School, we look at how we can administer our machines remotely using Remote Assistance, Remote Desktop, Windows Remote Management also known as WinRM, and PowerShell.
在此Geek School安裝中,我們研究了如何使用遠程協助,遠程桌面,Windows遠程管理(也稱為WinRM)和PowerShell遠程管理計算機。
Be sure to check out the previous articles in this Geek School series on Windows 7:
請務必查看Windows 7上此Geek School系列中的先前文章:
Introducing How-To Geek School
入門方法極客學校
Upgrades and Migrations
升級和遷移
Configuring Devices
配置設備
Managing Disks
管理磁盤
Managing Applications
管理應用程式
Managing Internet Explorer
管理Internet Explorer
IP Addressing Fundamentals
IP尋址基礎
Networking
聯網
Wireless Networking
無線網絡
Windows Firewall
Windows防火墻
And stay tuned for the rest of the series all this week.
并繼續關注本周剩余的系列節目。
遠程協助 (Remote Assistance)
Remote assistance is a feature which first debuted in Windows XP, and besides the removal of voice chat has remained unchanged. When using remote assistance there are two users connected to one machine, using it as the same time. Firstly there is the person needing assistance who is also known as the host as well as the person assisting the user who is called the helper. Remote assistance is centered around the idea of a virtual helpdesk kind of scenario.
遠程協助是Windows XP中首次亮相的功能,此外,語音聊天的刪除保持不變。 使用遠程協助時,有兩個用戶連接到一臺計算機,同時使用它。 首先,有一個需要幫助的人,也被稱為主持人,還有一個幫助用戶的人,稱為幫助者。 遠程協助圍繞虛擬服務臺這種情況的思想進行。
In order for a someone to request help, they need to send you an invitation to help them. There are three ways you can generate an invitation:
為了使某人請求幫助,他們需要向您發送邀請以幫助他們。 您可以通過三種方式生成邀請:
If both the host and the helper are on the same network you can save a file to a network location.
如果主機和幫助程序都在同一網絡上,則可以將文件保存到網絡位置。
If they are not on the same network you can send them an email invitation.
如果他們不在同一網絡上,則可以向他們發送電子郵件邀請。
If your network is running IPv6, which is highly unlikely at this point in time, you can use easy connect.
如果您的網絡正在運行IPv6(目前不太可能),則可以使用easy connect 。
The host is also has the final say of what goes on in the session, for example they can choose whether the helper can control the mouse and keyboard and can even disconnect the session at anytime should they feel uncomfortable with what the helper is doing.
主持人還可以最終確定會話中發生的事情,例如,他們可以選擇幫助者是否可以控制鼠標和鍵盤,甚至可以在他們對助手的操作感到不舒服時隨時斷開會話。
啟用遠程協助 (Enabling Remote Assistance)
To enable Remote Assistance, open the Start Menu and right click on Computer, then select Properties from the context menu.
要啟用遠程協助,請打開“開始”菜單,右鍵單擊“計算機”,然后從上下文菜單中選擇“屬性”。

When the System Information dialog opens, click on the Remote settings link located on the left hand side.
當“系統信息”對話框打開時,單擊左側的“遠程設置”鏈接。

Here you will need to check the box that allows Remote Assistance connections to your computer.
在這里,您需要選中允許遠程協助連接到計算機的復選框。

If you click on the advanced button you can change things like whether the helper will be allowed to take control of your mouse and keyboard as well as how long invitations that you generate are valid for.
如果單擊高級按鈕,則可以更改諸如是否允許助手控制您的鼠標和鍵盤以及所生成邀請的有效期限之類的信息。

使用遠程協助 (Using Remote Assistance)
In order to request for someone to help you, you need to make an invitation. To do that open the start menu, expand maintenance and choose Windows Remote Assistance.
為了請求某人幫助您,您需要發出邀請。 為此,請打開“開始”菜單,展開“維護”,然后選擇“ Windows遠程協助”。

Then choose to invite someone you trust to help you.
然后選擇邀請您信任的人來幫助您。

For demonstration purposes I am going to save the invitation out to a file, but feel free to use whatever method you want.
出于演示目的,我將邀請保存到文件中,但可以隨時使用所需的任何方法。

I have shared my documents library with another PC on my network so saving the invitation in here is perfect.
我已經與網絡上的另一臺PC共享了文檔庫,因此將邀請保存在這里非常完美。

Once you have saved the invitation you will be given a password. This is very important as the helper will need to enter this when they try and connect to your PC.
保存邀請后,您將獲得一個密碼。 這非常重要,因為幫助者在嘗試連接到PC時將需要輸入該信息。

I have switched over to a machine running Windows 8. I chose to do this so that you don’t get confused about which PC I’m on. From the Windows 8 machine I simply double click on the invitation.
我已切換到運行Windows 8的計算機。我選擇執行此操作,以免您對正在使用的PC感到困惑。 在Windows 8計算機上,我只需雙擊邀請即可。

I then enter the password that my buddy, on the on host machine sent to me and click ok.
然后,我在主機上發送給我的好友的密碼發送給我,然后單擊“確定”。

The host will then be asked if they want to allow me to connect to their machine. In this case I know who is trying to connect and so I can click Yes.
然后,將詢問主機他們是否要允許我連接到他們的計算機。 在這種情況下,我知道誰在嘗試連接,因此可以單擊“是”。

That’s all there is to it. I can now see exactly what you are doing on your Windows 7 computer in real time. If you allowed users to take control of your PC, as seen under the advanced options section, you will see a request control button as seen below. The host will then be allowed to allow or deny your request. You can also use the chat feature if you so choose.
這里的所有都是它的。 現在,我可以實時準確地看到您在Windows 7計算機上正在做什么。 如高級選項部分所示,如果允許用戶控制您的PC,則將看到一個請求控制按鈕,如下所示。 然后,將允許主機允許或拒絕您的請求。 您也可以選擇使用聊天功能。

遠程桌面 (Remote Desktop)
While Remote Assistance is focused around a two user scenario, Remote Desktop is focused around a single user. The biggest difference between Remote Assistance and Remote Desktop is that when I connect to a remote desktop session, the computer I am connecting to gets locked so that anyone walking by can’t see what I am doing on that machine. As you probably have guessed by now, Remote Desktop is focused around productivity. For example, if I forgot to edit a document before I left work, when I get home I could use Remote Desktop to connect to that machine and it would be like I am sitting at my desk.
遠程協助專注于兩個用戶的方案,而遠程桌面專注于單個用戶的方案。 遠程協助和遠程桌面之間的最大區別在于,當我連接到遠程桌面會話時,我連接的計算機將被鎖定,以使任何路過的人都看不到我在那臺計算機上正在做什么。 您可能已經猜到了,遠程桌面專注于生產力。 例如,如果我在下班前忘了編輯文檔,當我回到家時,我可以使用遠程桌面連接到該計算機,就像我坐在辦公桌前一樣。
Note: This is so useful I even use it every day at home where I have a couple of servers with no screen attached to them; in fact, they don’t even have a keyboard or mouse. They simply have a power cable and a network cable, that’s all. When I want to to something on the server I simply use remote desktop.
注意:此功能非常有用,我什至每天在家中都使用幾臺服務器,而這些服務器均未連接屏幕; 實際上,他們甚至沒有鍵盤或鼠標。 它們僅具有電源線和網絡線即可。 當我想在服務器上進行操作時,我只是使用遠程桌面。
啟用遠程桌面 (Enabling Remote Desktop)
To enable Remote Desktop, open the Start Menu and right click on Computer, then select Properties from the context menu.
要啟用遠程桌面,請打開“開始”菜單,右鍵單擊“計算機”,然后從上下文菜單中選擇“屬性”。

When the System Information dialog opens, click on the Remote settings link located on the left hand side.
當“系統信息”對話框打開時,單擊左側的“遠程設置”鏈接。

Here you will need to check the box that allows Remote Desktop connections to your computer. There are two options for enabling Remote Desktop:
在這里,您需要選中允許遠程桌面連接到計算機的復選框。 啟用遠程桌面有兩個選項:
- Simply allowing connection from any device that implements the Remote Desktop Protocol. This is less secure but allows you to connect to your PC from devices that don’t run Windows for example, an iOS device or even another computer that is running Linux. 只需允許實現遠程桌面協議的任何設備進行連接即可。 這種方法的安全性較差,但允許您從不運行Windows的設備(例如iOS設備或什至另一臺運行Linux的計算機)連接到PC。
- Alternatively, you can choose to allow connections from Windows 7 or later machines, which implement the RDP with Network Level Authentication. 或者,您可以選擇允許來自Windows 7或更高版本的計算機的連接,這些計算機通過網絡級身份驗證實現RDP。
We can go with the more secure option since I only have computers running Windows 7 and later in my environment.
我們可以選擇更安全的選項,因為我的環境中只有運行Windows 7及更高版本的計算機。

使用遠程桌面 (Using Remote Desktop)
Once you have enabled Remote Desktop on a computer it is very easy to connect to it. To do so, open the Start Menu and expand Accessories, then click on Remote Desktop Connection.
在計算機上啟用遠程桌面后,很容易連接到它。 為此,請打開“開始”菜單并展開“附件”,然后單擊“遠程桌面連接”。

Now you will need to enter the name or IP address of the machine with Remote Desktop enabled, then click connect.
現在,您需要輸入啟用了遠程桌面的計算機的名稱或IP地址,然后單擊連接。

You will be prompted for credentials. Remember: you will need to input credentials of a user on the remote machine and not the one you are connecting from.
系統將提示您輸入憑據。 請記住:您將需要輸入遠程計算機上的用戶憑據,而不是您要連接的用戶的憑據。

That’s all there is to it. It will now feel like you are sitting at the remote machine.
這里的所有都是它的。 現在感覺就像您坐在遠程計算機上一樣。

One thing you will notice is that you lose a lot of the visual effects when you use RDP. If you are on a LAN and have Gigabit Ethernet, you may want to change this. To do so, before you connect, click on the options drop down.
您會注意到的一件事是,使用RDP會損失很多視覺效果。 如果您在局域網上并且具有千兆以太網,則可能需要更改此設置。 為此,在連接之前,請單擊選項下拉菜單。

Then switch over to the Experience tab. Here you can choose the speed of you connection, which will determine the optimum settings for you.
然后切換到“體驗”選項卡。 在這里,您可以選擇連接速度,這將為您確定最佳設置。

WinRM (WinRM)
Note: WinRM is a solid management tool but as you will see in a little while it has been superseded by the ever amazing PowerShell Remoting feature.
注意:WinRM是一個可靠的管理工具,但是不久之后,您將看到它已被功能強大的PowerShell Remoting功能所取代。
Windows Remote Management is a command line-based management protocol. The thing that WinRM really had going for it was that is was based upon the solid HTTP protocol that is allowed through many corporate firewalls, so there was no need to get special ports opened. WinRM doesn’t come enabled on Windows 7 and you will have to manually enable it on the workstations and servers you wish to manage remotely. In order to enable it open an elevated command prompt and run:
Windows遠程管理是基于命令行的管理協議。 WinRM真正要做的是基于許多公司防火墻允許的可靠HTTP協議,因此不需要打開特殊端口。 Windows 7并未啟用WinRM,您必須在要遠程管理的工作站和服務器上手動啟用WinRM。 為了啟用它,請打開提升權限的命令提示符并運行:
winrm quickconfig
Winrm QuickConfig

The following system changes take place when you enable WinRM:
啟用WinRM時,將發生以下系統更改:
- The Windows Remote Management service gets changed to delayed automatic start. Windows遠程管理服務已更改為延遲的自動啟動。
- It will create HTTP listeners on all local IP addresses 它將在所有本地IP地址上創建HTTP偵聽器
- A firewall exception will be created將創建防火墻例外
That’s really all there is to setting your computer up for WinRM.
這實際上是為WinRM設置計算機的全部功能。
連接到啟用WinRM的計算機 (Connecting to a WinRM Enabled Computer)
In order to connect to a computer using WinRM you have to add the machine to your trusted hosts list. To do that simple type in the following command:
為了使用WinRM連接到計算機,您必須將計算機添加到“受信任的主機”列表中。 為此,請輸入以下命令:
Note: You will need to change the IP in the command below to the one of the machine you are trying to connect to.
注意:您需要將以下命令中的IP更改為您嘗試連接的計算機之一。
winrm set winrm/config/client @{TrustedHosts=”192.168.174.130”}
winrm設置winrm / config / client @ {TrustedHosts =” 192.168.174.130”}
Once you have added the machine to your TrustedHosts, you can connect and run any command you want on the remote machine. To do so you use the Windows Remote Shell (WinRS) command.
將計算機添加到TrustedHosts之后,就可以連接并在遠程計算機上運行所需的任何命令。 為此,您可以使用Windows Remote Shell(WinRS)命令。
winrs –r:192.168.174.130 –u:Taylor –p:Pa$$w0rd netstat
winrs –r:192.168.174.130 –u:Taylor –p:Pa $$ w0rd netstat
You will need to substitute the following values:
您將需要替換以下值:
192.168.174.130 for the IP address of a machine with WinRM enabled
啟用WinRM的計算機的IP地址為192.168.174.130
Taylor for the username of a local administrator on the remote machine
Taylor為遠程計算機上本地管理員的用戶名
Pa$$w0rd for the password for the user account specified above.
Pa $$ w0rd為上面指定的用戶帳戶的密碼。
netsat for the command you want to run. Of course, if you really want to see the listening ports on the remote machine, feel free to use netsat.
您要運行的命令的netsat 。 當然,如果您真的想查看遠程計算機上的偵聽端口,請隨時使用netsat。

PowerShell遠程處理 (PowerShell Remoting)
As I mentioned earlier, PowerShell’s Remoting feature is built on top of WinRM. So let’s establish what sets it apart from the legacy shell.
如前所述,PowerShell的Remoting功能是基于WinRM構建的。 因此,讓我們建立將其與傳統Shell區別開的原因。
Object Orientation
面向對象
There is one thing that makes PowerShell as powerful as it is, and that thing is called Object Orientation. Object Oriented Programming, or OOP as it has come to be known, is a style of programming that supports code reuse. One of the methods it uses to accomplish this is allowing you to create compound data structures that are made up of primitive data types like numbers and strings as well as other compound structures. These compound data structures are called objects.
有一件事情可以使PowerShell保持其強大的功能,而這又稱為對象定向。 面向對象編程(OOP)是一種支持代碼重用的編程風格。 它用來實現此目的的方法之一是允許您創建由原始數據類型(例如數字和字符串)以及其他復合結構組成的復合數據結構。 這些復合數據結構稱為對象。
Put simply, an object is a representation of something. Objects contain properties that describe the thing, and methods that tell the object what it can do. For example, you might have an object called Person. The Person object would have:
簡而言之,對象就是事物的表示。 對象包含描述事物的屬性,以及告訴事物它可以做什么的方法。 例如,您可能有一個名為Person的對象。 Person對象將具有:
- A property describing the color of the person’s eyes. 描述人眼顏色的屬性。
- A property describing the color of the person’s hair. 描述人的頭發顏色的屬性。
- It might have a method called sleep. 它可能有一種稱為睡眠的方法。
- It might have a method called walk. 它可能有一個叫做walk的方法。
OOP is actually much more than this, but this will serve as a working definition for now. Since everything in PowerShell is an object, it’s really easy to work with data. For example, the Get-Service cmdlet gets information about services running on your local machine. To see what kind of object it outputs, simply pipe it to Get-Member:
OOP實際上不止于此,但是現在這將作為一個可行的定義。 由于PowerShell中的所有內容都是一個對象,因此使用數據真的很容易。 例如,Get-Service cmdlet獲取有關在本地計算機上運行的服務的信息。 要查看其輸出的對象類型,只需將其通過管道傳遞到Get-Member:
Get-Service | Get-Member
服務獲取| 獲得會員

Here you can see it outputs a type of object called a ServiceController. You can also see the Methods and Properties that ServiceController objects support. Given this information, it’s fairly trivial to figure out that you could stop a service by calling the Kill method on the object that represents the service you want to stop.
在這里,您可以看到它輸出一種稱為ServiceController的對象。 您還可以查看ServiceController對象支持的方法和屬性。 有了這些信息,弄清楚您可以通過在表示要停止的服務的對象上調用Kill方法來停止服務,這是很簡單的。
遠程處理 (Remoting)
Since we have set up WinRM, our Windows 7 machine is already capable of being remotely controlled via PowerShell. To run a powershell cmdlet on a remote machine you use the Invoke-Command cmdlet:
由于我們已經設置了WinRM,因此我們的Windows 7計算機已經能夠通過PowerShell進行遠程控制。 要在遠程計算機上運行powershell cmdlet,請使用Invoke-Command cmdlet:
Invoke-Command WIN-H7INVSHKC7T {get-service}
調用命令WIN-H7INVSHKC7T {獲取服務}

That’s all there is to it.
這里的所有都是它的。
If you have any questions you can tweet me @taybgibb, or just leave a comment.
如果您有任何疑問,可以發給我@taybgibb ,或發表評論。
翻譯自: https://www.howtogeek.com/134679/geek-school-learning-windows-7-remote-administration/
進化:從孤膽極客到高效團隊