Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystemObject to Add Domain Group as Local Admin

Status
Not open for further replies.

dgoldb1

IS-IT--Management
Aug 3, 2006
4
0
0
US
I am interested in adding a domain group to a local admin account through a script. I found a script that does this but it only does one computer at a time, I am looking to do more than that. I have pasted the script below:

strComputer = "atl-ws-01"

Set objAdmins = GetObject("WinNT://" & strComputer & "/Administrators")
Set objGroup = GetObject("WinNT://fabrikam/accounting")

objAdmins.Add(objGroup.ADsPath)


Is there any way to make this script pull from a txt file with a list of computers, maybe delineated by commas or returns? I know you can use the FileSystemObject funstion but not sure how to incorporate it. I don't really feel like running this manually 400 times

Thanks for the help.

DG
 
Try this:

Code:
Set FSO = CreateObject("Scripting.FileSystemObject")
    strFile = App.Path & "\FileName.txt"
    If FSO.fileexists(strIniPath) Then
        Set txtFile1 = FSO.OpenTextFile(strFile , 1, False)
        On Error GoTo ExitErr
        
        Do While Not txtFile1.AtEndOfStream
        
            strLine = txtFile1.readline
            strComputer =strLine
            
        Loop
        
    End If
ExitErr:
    txtFile1.Close

Just add the names of your computers to a text file that is in the application directory.

I hope this helps.



Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top