ActiveXperts Network Monitor
Monitor servers, workstations, devices and applications in your network

Quicklinks


Local Computer and NT4 Groups Scripting (SAM Database)

Create a Local Group on a Computer
Delete a Local Group
Delete a User from a Local Group
List All the Local Groups a User Belongs To
List Local Groups and Their Members


You can use any of the VBScript programs below in ActiveXperts Network Monitor. Click here for an explanation about how to include scripts in ActiveXperts Network Monitor.



Create a Local Group on a Computer


Creates a local group named FinanceUsers on a computer named atl-ws-01.
strComputer = "atl-ws-01"
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("group", "FinanceUsers")
objUser.SetInfo
	

Delete a Local Group


Deletes a local group named FinanceUsers from a computer named atl-ws-01.
strComputer = "atl-ws-01"
Set objComputer = GetObject("WinNT://" & strComputer & "")
objComputer.Delete "group", "FinanceUsers"
	

Delete a User from a Local Group


Removes kenmyer from the local Administrators group on a computer named atl-ws-01.
strComputer = "atl-ws-01"
Set objGroup = GetObject("WinNT://" & strComputer & "/Adminstrators,group")
Set objUser = GetObject("WinNT://" & strComputer & "/kenmyer,user")
 
objGroup.Remove(objUser.ADsPath)
	

List All the Local Groups a User Belongs To


Returns a list of all the local groups on the computer atl-win2k-01 that a user named kenmyer belongs to.
strComputer = "atl-win2k-01"
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")

For Each objGroup In colGroups
    For Each objUser in objGroup.Members
        If objUser.name = "kenmyer" Then
            Wscript.Echo objGroup.Name
        End If
    Next
Next
	

List Local Groups and Their Members


Returns a list of local groups (and their members) found on a computer named atl-win2k-01.
strComputer = "atl-win2k-01"
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")

For Each objGroup In colGroups
    Wscript.Echo objGroup.Name 
    For Each objUser in objGroup.Members
        Wscript.Echo vbTab & objUser.Name
    Next
Next