Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Domain Admin from Administrator

Hi,

I need to find who all users do not have Domain Admin rights on the computer.Some users remove the Domain Admin rights from the Administrator/Username.Please guide to to find a way who all have removed it or a way to give these rights remotely.

Regards
Sharath
Avatar of younghv
younghv
Flag of United States of America image

Sharath,
Another case for Hyena.
You can use it to 'push' the addition of any account (or User Group) to the local Administrator Group on the individual host.
If the account or group is already there, it will just continue to the next computer on the list.
It will also 'log' the activity and give you a report of the results.

Vic
Save this as FindAdmins.vbs and run it by double-clicking it.
The only piece that needs to be changed is
'LDAP://dc=fabrikam,dc=com - to match your domain...


On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Dim objFSO:Set objFSO=CreateObject("Scripting.FileSystemObject")
Dim objOutput: Set objOutput=objFSO.CreateTextFile("C:\AdminReport.txt")
Set objConn = CreateObject("ADODB.Connection")
Set objCmd =   CreateObject("ADODB.Command")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
Set objCmd.ActiveConnection = objConn
objCmd.Properties("Page Size") = 1000
objCmd.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCmd.CommandText = _
    "SELECT Name, distinguishedName FROM 'LDAP://dc=fabrikam,dc=com' " _
        & "WHERE objectCategory='computer'"  
Set objRS = objCmd.Execute

objRS.MoveFirst
Do Until objRS.EOF
   Set objGroup = GetObject("WinNT://" & objRS.Fields("Name") & "/Administrators")
  objOutput.WriteLine "Administrators on " & objRS.Fields("Name")
  For Each objUser in objGroup.Members
        objOutput.WriteLine vbTab & objUser.Name
    End If
  Next
  objRS.MoveNext
Loop

objOutput.Close
Set objOutput=Nothing
Set objFSO=Nothing
Avatar of bsharath

ASKER

Sirbounty

I get this error

C:\>cscript admin.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\admin.vbs(23, 5) Microsoft VBScript compilation error: Expected statement
Hmm - not sure why that was there...remove this line:
 End If (on line 23)
Now i get this error.

C:\>cscript a.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\a.vbs(1, 11) Microsoft VBScript compilation error: Expected end of statement
11 appears to be...objCmd.Properties("Searchscope") = ADS_SCOPE_SUBTREE

This should be the full code...

'Start copying here...
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objOutput: Set objOutput = objFSO.CreateTextFile("C:\AdminReport.txt")
Set objConn = CreateObject("ADODB.Connection")
Set objCmd = CreateObject("ADODB.Command")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
Set objCmd.ActiveConnection = objConn
objCmd.Properties("Page Size") = 1000
objCmd.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCmd.CommandText = _
    "SELECT Name, distinguishedName FROM 'LDAP://dc=fabrikam,dc=com' " _
        & "WHERE objectCategory='computer'"
Set objRS = objCmd.Execute

objRS.MoveFirst
Do Until objRS.EOF
   Set objGroup = GetObject("WinNT://" & objRS.Fields("Name") & "/Administrators")
  objOutput.WriteLine "Administrators on " & objRS.Fields("Name")
  For Each objUser In objGroup.Members
        objOutput.WriteLine vbTab & objUser.Name
  Next
  objRS.MoveNext
Loop

objOutput.Close
Set objOutput = Nothing
Set objFSO = Nothing
sirbounty:
Sorry for the delay.
This script does not respond once i excecute it is only shows a command prompt blank screen.

Please advice.

THX
Sharath
Should be compiling into C:\AdminReport.txt

Do you see that file?  Does it have any data in it?
The no data in the file i checked that also
There is no data in the file i checked that also

THX
Sharath
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial