Using the command line to improve the management efficiency of Windows Server 2008

  
A skilled and technically deep server administrator, they often deprecate a friendly graphical interface and choose to use the command to manage the server. This not only improves work efficiency, but also enables many tasks that cannot be done under the graphical interface on the command line. This is especially true for server operating systems such as Windows Server 2008, where the use of commands greatly liberates administrators. The author below introduces you to several very useful commands in Server 2008.

1. Server Management with ServerManagerCMD Command

ServerManagerCMD is a server-line command line tool that supports three important operations: adding and removing roles, role services, functions, and for display. Installed roles, role services, features. For specific parameters, you can enter "ldManager; ServerManagerCMD /?" in the command line to view. Among them, -query, -install, and -remove are the three most commonly used parameters for users to query, install, and delete server roles, role services, and functions. The author below demonstrates the usage of these three parameters.

(1). Query

Enter the command “ServerManagerCMD -query” in the command prompt window, you can view the configuration and functions of the server after the carriage return, thus eliminating the need to “Service Manager” graphical interface to switch back and forth. The results are clear: the roles and functions are divided into two groups. The installed roles, role services, and functions are displayed in green and have the [X] logo in front of the item. The unmounted display is white and the front is identified as [ ]. As shown in Figure 1, the server roles installed by the server are: Active Directory Domain Services, DNS Server, Windows Deployment Services, and the installed functional components are: TFTP client, Group Policy Manager. In addition, the installed role services are displayed in a hierarchy below the corresponding roles. (Figure 1)



The author also has a technique to share with you: When the server has multiple roles, role services, and functional components installed, if the administrator wants to see if it is installed. This will be more troublesome for an object. In fact, ServerManagerCMD -query supports pipeline commands “| ”, we can do this: If we want to check whether the server has the Group Policy Management component installed, you can type "ServerManagerCmd.exe -query" at the command line.  GPMC”, if you install this component after the carriage return, the tool will be opened, otherwise an error message will be displayed (such as entering the command “ServerManagerCmd.exe -query |  RSAT-TS”Check if the Terminal Services tool is installed, because no installation will output an error). (Figure 2)

(2). Installation

Windows Server 2008 does not install the telnet client by default. If we want to install this feature, we can at the command prompt. Enter the command “ServerManagerCmd.exe -install Telnet-Client -resultPath installResult.xml” and press Enter. At this point, the installation of the Telnet-Client function component is started, and the progress (percentage) of the installation is displayed in real time, and the installation is completed soon. In the above command, “Telnet-Client” is the system name of the Telnet client. You must not use Chinese in English. Otherwise, “Invalid role, role service or function” will be displayed. Of course, it shouldn't be difficult for a skilled server administrator to remember these names. If you forget, you can view it by the above query command “ServerManagerCmd.exe -query”. “-resultPath installResult.xml” The function of the parameter is to save the result of the operation to the installResult.xml file in XML format. In addition, if the installed role needs to restart the computer, we can add a parameter "-restart" to the end to automatically restart the system after the installation is completed to make the installation take effect. (Figure 3)
(3). Delete

To delete the server role, role service or function component, the operation method is similar to the above, just change the parameters of the ServerManagerCmd.exe command. For example, if we want to delete both the "Windows Deployment Service" role and the "TFTP Client" function component, you can enter the command "ServerManagerCMD -remove WDS TFTP-Client" at the command prompt and press Enter. Then start deleting and showing the progress of the deletion, and wait a moment to complete the deletion task. If you want to delete more characters or functions, just enter the name of the character or function and separate them with spaces, which is much faster than the operation in the graphical interface. (Figure 4)



2. Quickly configure server components

The configuration of the server is not only technical, but also physical. How do server administrators implement rapid server configuration to improve productivity and self-liberation? Using commands and scripts is an immediate solution. Here are a few practical examples.

(1). Configuring the firewall

Firewall configuration is an important aspect of server security deployment, and it is also a tedious task. Especially for server platforms like Windows Server 2008, its system firewall functionality is very powerful and has a lot of configurable items. Here are a few useful commands and a configuration case.


Open a command prompt and enter the input command <quo;netsh firewall show state” Then press Enter to check the status of the firewall. From the displayed results, you can see the disable and enable of each function module of the firewall. Happening. The command "netsh firewall set opmode disable" is used to disable the system firewall. Instead, the command "netsh firewall set opmode enable" enables the firewall. (Figure 5)



Next we configure the firewall through the command line to allow access to file and print sharing and DNS queries. Open a command prompt and enter the command "netsh firewall add portopening UDP 53 DNS-Server" and press Enter. After the command is executed, the server can respond to the client's DNS query request and provide DNS service for it. It is very simple to get a command. Next, we can use the command to enable the client to access the server through file and print sharing. Enter and execute the following commands respectively: <;netsh firewall add portopening UDP 137 Netbios-ns” (allows the client to access the server UDP protocol port 137), “ Netsh firewall add portopening UDP 138 Netbios-dgm” (allows access to UDP port 138), <;netsh firewall add portopening TCP 139 Netbios-ssn” (allows access to TCP port 139), <;netsh firewall add portopening TCP 445 Netbios-ds” (allows access to port 445 of the TCP protocol). After the command is executed, the ports required for file and print sharing are released by the firewall. We tried it successfully from the client. Although the above commands are quite numerous, the format is similar and very easy to remember. (Figure 6)



Previous 12 Next Read more

Copyright © Windows knowledge All Rights Reserved