Roberto Alves

Scripting and server based computing

.VBS script to verify what members belongs to local Administrators group

This simple .VBS script can verify in seconds what members belongs to local Administrators group and Power Users groups of all servers.
You only need inform the names of each server in a text file called servers.txt.

On Error Resume Next
Set objFSO = CreateObject(“Scripting.FileSystemObject”)

Set servidores = objFSO.OpenTextFile(“servers.txt”, 1)
Set eventos = objFSO.OpenTextFile(“result.htm”,2)
eventos.WriteLine “<br>”
eventos.WriteLine “<TABLE BORDER=’2′ BORDERCOLOR=’#000000′>”
Do Until servidores.AtEndOfStream
eventos.WriteLine “<tr><Td>”
server = servidores.ReadLine
If objFSO.FolderExists(“”& server & “c$windows”) Then
Set colGroups = GetObject(“WinNT://” & server & “”)
colGroups.Filter = Array(“group”)
eventos.writeline “<tr><td><b>”
eventos.writeline server
eventos.writeline “</b></td>”
For Each objGroup In colGroups
if objGroup.Name= “Administrators” or objGroup.Name= “Power Users” then
eventos.writeline “<td><b>”
eventos.writeline objGroup.Name
eventos.writeline “</b><br>”
For Each objUser in objGroup.Members
‘eventos.writeline “<>”
eventos.WriteLine “   ” & objUser.Name
eventos.writeline “<br>”
eventos.writeline “</td>”
end if
eventos.writeline “</tr>”
eventos.writeline “<td><tr>”
eventos.WriteLine “ERROR on server: ” & server
eventos.writeline “</td></tr>”
End If
eventos.WriteLine “</Td></tr>”
eventos.WriteLine “</TABLE><BR>”
wscript.echo “It is done!!!”

Category: Scripts
Tag: , ,

Your email address will not be published. Required fields are marked *