Home » VbScript » List the Local Administrator Group Members

List the Local Administrator Group Members


Result.txt will be on C: Drive
—————————————————————————————————————————————-
dim fso, wshNetwork, wshShell, computer, LALog
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set wshNetwork = CreateObject(“WScript.Network”)
Set wshShell = CreateObject(“WScript.Shell”)

Computer = wshNetwork.ComputerName

Set LALog = fso.CreateTextFile(“c:\result.txt”,2,true)

Set objComp = GetObject(“WinNT://” & Computer)
objComp.GetInfo
If objComp.PropertyCount > 0 Then
Set objGroup = GetObject(“WinNT://” & Computer & “/Administrators,group”)
If objGroup.PropertyCount > 0 Then

LALog.WriteLine “The members of the local Administrators group on ” & Computer & ” are:”
For Each mem In objGroup.Members
LALog.WriteLine vbTab & Right(mem.AdsPath,Len(mem.AdsPath) – 8)
Next
Else
LALog.WriteLine “** Connecting to the local Administrators group on ” & Computer & ” failed.”
WScript.Quit 1
End If
Else
LALog.WriteLine “** Connecting to ” & Computer & ” failed.”
WScript.Quit 1
End If

LALog.Close
—————————————————————————————————————————————-

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: