Hello,
I have this script below.
Someone can help me and explain me how to add a way to dynamically fill the name of Administrators group depending of the computer (for some computers it's "Administrateurs", for others "Administrators", etc...
(cf line : "Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
If objGroup.PropertyCount > 0 Then")
Thank you in advance
on error resume next
strComputer = Wscript.Arguments.Item(0)
If strComputer = "" Then
' strComputer = "."
Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputer = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
' WScript.Echo "Computer Name: " & strComputer
End If
call CompareLocalAdmins(strComputer)
WScript.Quit 0
'--------------------------------------------------
'- Compare Local Admins to List of Valid Accounts -
'--------------------------------------------------
Sub CompareLocalAdmins(RemoteSystem)
Dim objComp
strComputer = RemoteSystem
Set objComp = GetObject("WinNT://" & strComputer)
objComp.GetInfo
If objComp.PropertyCount > 0 Then
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
If objGroup.PropertyCount > 0 Then
' WScript.Echo "QUESTIONABLE members of local Admins group on " & strComputer & " are:"
okflag = "Y"
For Each mem In objGroup.Members
memx = LCase(mem.Name)
'List of locally-authorized admins against which to compare
If (memx = "Group1" or memx = "administrator") Then
'WScript.Echo "A-OKAY!"
'Note: "special-admin" above is an example of a locally-authorized admin
Else
okflag = "N"
WScript.Echo strComputer & "," & mem.Name & ",BAD"
End If
Next
If okflag = "Y" Then
WScript.Echo strComputer & ",ALLOK"
End If
Else
WScript.echo "Unable to check remote computer: " & strComputer
WScript.Quit 1
End If
Else
WScript.Echo "Unable to check remote computer: " & strComputer
WScript.Quit 1
End If
End Sub