Windows Scripting
  Home arrow Windows Scripting arrow Page 6 - Modifying Computer Objects with Active Dir...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Modifying Computer Objects with Active Directory
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2008-01-31

    Table of Contents:
  • Modifying Computer Objects with Active Directory
  • Finding Computers with a Particular OS
  • Binding to the Default Container for Computers
  • Changing the Default Container for Computers
  • Listing All the Computer Accounts in a Domain
  • Identifying a Computer Role

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    IBM developerWorks
     
    ADVERTISEMENT

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    Modifying Computer Objects with Active Directory - Identifying a Computer Role


    (Page 6 of 6 )

    Problem

    You want to identify the role that a particular computer serves in an Active Directory domain. 

    Solution

    Using a graphical user interface

    1. Open the Active Directory Users and Computers MMC snap-in.
    2. Right-click on the domain node and select Find.
    3. In the Find drop-down box, select Computers and click Find Now.

      The role of each computer will be displayed in the Machine Role column in the Search Results window.

    Using a command-line interface

      > wmic computersystem get domainrole

    For a domain controller that holds the PDC Emulator FSMO role, this will return the following output:

      DomainRole
      5

    For a DC that doesn’t hold the PDCe FSMO, this command will return a value of 4.

    Using VBScript

      ' The following code will return the domain role of the
      ' local computer.
      strComputer = "."
      Set objWMIService = GetObject("winmgmts:" _
          & "{impersonationLevel=impersonate}!" _
          & strComputer & "\root\cimv2")
      Set colComputers = objWMIService.ExecQuery _
          ("Select DomainRole 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

    Discussion

    Using a command-line interface

    WMIC is the command-line component of the Windows Management Instrumentation that uses aliases to enable you to easily access WMI namespaces from the command line. To run wmic against a remote computer, specify the /node:"<ComputerFQDN> " switch.

    Using VBScript

    Rather than relying on an if...else construct to produce output, this script uses Select Case. In situations where there are numerous possible outcomes for a conditional statement, Select Case can produce far more elegant code than using numerous if...else statements.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This article is an excerpt from the "Active Directory Cookbook, Second Edition,"...
     

    Buy this book now. This article is excerpted from chapter eight of the Active Directory Cookbook, Second Edition, written by Robbie Allen and Laura E. Hunter (O'Reilly; ISBN: 059610202X). Check it out today at your favorite bookstore. Buy this book now.

    WINDOWS SCRIPTING ARTICLES

    - Understanding Procedures in VBScript
    - Printing Documents in WSH
    - Generating Outlook Signatures Based on Activ...
    - VBScript: Converting and Formatting with Fun...
    - VBScript: Conversion and Format Functions
    - VBScript: Array Functions
    - VBScript: Strings, You Can`t Function withou...
    - VBScript: More String Functions
    - VBScript: Functioning with Strings
    - Working with the Windows Registry in C++
    - Understanding Objects
    - HTML Applications: Giving WSH a User Interfa...
    - Modifying Computer Objects with Active Direc...
    - Logon Script to Send Email Notifications
    - Securing Computers and Active Directory





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway