Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
The way in which you manage a specific computer depends greatly on the role that computer plays. For example, you generally monitor different aspects of a DNS server than a DHCP server. Although no single property can tell you whether a particular computer is a database server, an e-mail server, or a multimedia server, you can often identify the role a computer plays by identifying the services installed on it.
In large organizations, only one of the major services (such as e-mail) is likely to be installed on a single computer. It would be unusual for a mail server to also perform as a server for Microsoft® Windows Media® technologies player files. Because of this, identifying a service installed on a computer can help identify the computer s role in the network. If the Microsoft® Exchange Server service is installed and running on a computer, it is generally safe to assume that this computer functions as a mail server.
You can use the WMI Win32_Service class to enumerate the services installed on a computer. In addition, you can use this class to determine whether those services are currently running and to return any other required information about that service and how it has been configured.
Note
Listing 9.13 contains a script that identifies computer roles based on services installed on the computer. To carry out this task, the script must perform the following steps:
To limit the number of services returned, a Where clause is used to restrict data retrieval to those services with a registry name of MSSQLServer.
The Count property provides a quick way to determine whether any instances of Microsoft® SQL Server are installed on the computer. If the value of the Count property is 0, SQL Server is not installed. If the Count is greater than 0, SQL Server is installed.
If the service is installed, the script also echoes the current service state, that is, whether the service is running, paused, stopped, or resuming operation.
Listing 9.13 Identifying Computer Roles Based on Services
|
|
Send us your feedback | « Previous | Next » |