Identifying Computer Roles

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

It is important to know whether a computer is part of a domain because this helps determine the means by which a computer can be managed. Computers that do not belong to a domain and do not have accounts in Active Directory cannot be managed by using Group Policy or software installation and maintenance.

For example, a single domain-level Group Policy can be applied to computers that are members of a domain. Stand-alone computers, by contrast, must be managed on an individual basis by using local Group Policy. Domain membership also affects the availability of resources for anyone using that computer.

The role that a computer plays within a domain (workstation, server, or domain controller) also impacts the management of that computer. For example, when you use scripts that automatically install software or configure a computer, you need to know the computer role because:

  • Some software is designed for installation on workstations but not on servers.
  • Some services need to be configured by using a particular service account if they are being installed on a member server, but not if they are being installed on a domain controller.
  • Some software installation programs might automatically reboot the computer, and you might prefer that certain computers not be taken offline.

In these instances, verifying a computer s role before you install software or configure a service helps ensure that you install the correct software on the computer or use the correct service account for the role of the computer.

The DomainRole property of the Win32_ComputerSystem class can be used to identify the basic role of a computer and its membership in a domain. This property returns one of the values shown in Table 9.4.

Table 9.4   DomainRole Property Values

ValueDescription
0Stand-alone workstation (the computer is not a member of a domain)
1Member workstation
2Stand-alone server (the computer is not a member of a domain)
3Member server
4Backup domain controller
5Primary domain controller

Scripting Steps

Listing 9.12 contains a script that identifies the basic role of a computer. To carry out this task, the script must perform the following steps:

  1. Create a variable to specify the computer name.
  2. Use a GetObject call to connect to the WMI namespace root\cimv2 on the computer, and set the impersonation level to Impersonate.
  3. Use the ExecQuery method to query the Win32_ComputerSystem class.
  4. Retrieve the value of the DomainRole property.
  5. Convert the value of the DomainRole property to a string value, and then echo that result.

    This step is required because the DomainRole property is stored as an integer (for example, the value 0 for the DomainRole property means that the computer is a stand-alone workstation). This step converts the integer to the appropriate string value.

Listing 9.12   Identifying the Basic Role of a Computer

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 
strComputer = "." Set objWMIService = GetObject("winmgmts:" _     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colComputers = objWMIService.ExecQuery _     ("SELECT * FROM Win32_ComputerSystem") For Each objComputer in colComputers     Select Case objComputer.DomainRole         Case 0             strComputerRole = "Standalone Workstation"         Case 1                   strComputerRole = "Member Workstation"         Case 2             strComputerRole = "Standalone Server"         Case 3             strComputerRole = "Member Server"         Case 4             strComputerRole = "Backup Domain Controller"         Case 5             strComputerRole = "Primary Domain Controller"     End Select     Wscript.Echo strComputerRole Next

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net