Add Domain User to Local Admin on Multiple Servers
Add Domain User to Local Admin on Multiple Servers
Upon multiple requests, uploading my Old Script to Add Domain User to Local Admin on Multiple Servers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
'========================================================================== ' Author: Murali M Palla ' NAME: Add_Domain_User_to_Local_Administrators.vbs ' DATE : 2012-Nov-08 ' COMMENT: Takes the file servers.txt and outputs results to Job_Status.csv ' Version: V2 '========================================================================== On Error Resume Next Const ForReading = 1 Const ForAppending = 8 domain = InputBox("Enter the Domain Name ") myGroup = InputBox ("What NT DOMAIN User do you wish to add to the Local Administrator Group?") UserConfirmation= MsgBox ("You Entered : "&Domain&"\"&mygroup,vbYesNo) If UserConfirmation = vbYes Then Set objFSO = CreateObject("Scripting.FileSystemObject") Set SrvList = objFSO.OpenTextFile("servers.txt", ForReading) Set Reportfile = objFSO.CreateTextFile ("Job_Status.csv",True) Reportfile.WriteLine "Server Name" &"," & " Status " Do Until SrvList.AtEndOfStream strComputer = lcase(srvlist.readline) strDomainGroup = "WinNT://" & domain & "/" & myGroup & ",user" Set objDomainGroup = GetObject(strDomainGroup) Set objNetwork = CreateObject("Wscript.Network") Set objLocalGroup = GetObject("WinNT://" & strComputer & "/Administrators,group") If Err.Number <> 0 Then Reportfile.writeline UCase(strComputer) &","& Err.Number &"," & Err.Description Err.Clear Else If objLocalGroup.IsMember(objDomainGroup.AdsPath) Then Reportfile.WriteLine UCase(strComputer) &"," & Domain & "\" & myGroup &"," & " Is Already A Member of the Local Admin" Else objLocalGroup.Add(objDomainGroup.AdsPath) Reportfile.WriteLine UCase(strComputer) &"," & Domain & "\" & myGroup &"," & " Added to Local Admin" End If End if Loop WScript.Echo "Done, Please check Job_Status.csv" Else MsgBox ("Script Stoping per your confirmation") End If |
2,427 total views, 2 views today
Leave a Reply
You must be logged in to post a comment.