add and verify AD user in a local group

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Dave Benton (DaveBenton_at_discussions.microsoft.com)
Date: 09/22/04

  • Next message: Tom Lavedas: "RE: Ping servers from text file."
    Date: Wed, 22 Sep 2004 14:01:48 -0700
    
    

    We recently learned of the Network Configuration Operators (NCO) local group
    in XP. This thing will make many users happy. I would like write a script
    that will:
    1. input a list of PCs. The PC names match the user names.
    2. check to see if the user exists in the NCO group.
      - If yes , output the machine name and "already included".
      - If no, add the associated AD user to the PCs local NCO group, output the
    machine name and "added user".

    My current script is below. It will read the list and add the users as
    required. But I need the rest so I know who was not only at the time of it's
    running and who we need to go back and get.

    Any help is appreciated.

    'Constant declarations for File I/O
    Const ForReading = 1

    'Specify I/O files
    strPathIn = "C:\tools\scripts\testlist.txt" 'Path to text file listing servers

    'Create file system objects
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    If objFSO.FileExists(strPathIn) Then
     Set fsInput = objFSO.OpenTextFile(strPathIn,ForReading)
      
      do until fsInput.AtEndOfStream
          strComputer = fsInput.ReadLine
          On Error Resume Next
          WScript.Echo (strComputer)
          Set objGroup = GetObject("WinNT://" & strComputer & "/Network
    Configuration Operators,group")
          Set objUser = GetObject("WinNT:///domainname" & strComputer & ",user")
          objGroup.Add(objUser.ADsPath)
      Loop
    End If


  • Next message: Tom Lavedas: "RE: Ping servers from text file."