Login | |
|
 |
Re: delete/remove users from local administrators grou - 10/19/2004 11:27:52 PM
|
|
 |
|
| |
mbouchard
Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
|
To get the computername from a text file, Go here and download the Wscript documentation, look for info on readline. Once you have a script that can read through a text file post it here and i can help you use it with the remove user script below. To remove 1 user from the admin group, change this line: quote: If (sAdmGrpUser <> "administrator") And (sAdmGrpUser <> "domain admins") Then
To this: quote: If sAdmGrpUser = "abcdomain\joeuser" then
|
|
| |
|
|
|
 |
Re: delete/remove users from local administrators grou - 4/8/2005 4:48:59 PM
|
|
 |
|
| |
token
Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
|
The following script will delete a specific user account identify by the "username" variable from the local administrators group on a list of computers stored in a text file identified by the "src" variable. ================================================================================== Option Explicit Dim src, username src = "computers.txt" username = "test" cleanAdminGroup src, username Function cleanAdminGroup(file,username) Dim network, group, user, fso, temp, ts Set network = CreateObject("WScript.Network") Set fso = CreateObject("Scripting.FileSystemObject") If Not fso.FileExists(file) Then WScript.Echo "File does not exist: " & file Else Set ts = fso.OpenTextFile(file,1) Do Until ts.AtEndOfStream temp = ts.ReadLine Set group = GetObject("WinNT://" & temp & "/Administrators,group") For Each user In group.members If UCase(user.name) = UCase(username) Then group.remove user.adspath End If Next Loop End If End Function
|
|
| |
|
|
|
 |
Re: delete/remove users from local administrators grou - 4/11/2005 7:06:17 AM
|
|
 |
|
| |
token
Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
|
quote: Originally posted by colbytrio
quote: Originally posted by token Sure. Add the following line below and outside of the FOR EACH statement. group.add "domain\userID" should do the trick.
I'm very new to scripting so forgive me... I added that line directly under the "FOR EACH" statement but it didn't work. Do you mind entering it into the script where it should be exactly located? Thanks a ton for you help by the way. You have no idea how long we have been looking for a script like this. In an organization of 10,000+ users it's going to be a HUGE help.
Option Explicit Dim src, username src = "computers.txt" username = "test" cleanAdminGroup src, username Function cleanAdminGroup(file,username) Dim network, group, user, fso, temp, ts Set network = CreateObject("WScript.Network") Set fso = CreateObject("Scripting.FileSystemObject") If Not fso.FileExists(file) Then WScript.Echo "File does not exist: " & file Else Set ts = fso.OpenTextFile(file,1) Do Until ts.AtEndOfStream temp = ts.ReadLine Set group = GetObject("WinNT://" & temp & "/Administrators,group") For Each user In group.members If UCase(user.name) = UCase(username) Then group.remove user.adspath End If Next Loop group.add("WinNT://DOMAIN/Group_Name,group") End If End Function
|
|
| |
|
|
|
|
|