|
Posted by =?Utf-8?B?U3Rvb3BpdA==?= on June 26, 2007, 5:43 pm
If you were Registered and logged in, you could reply and use other advanced thread options How is this script normally run? Do you put it in a file with a particular
extension then run from command line? I noticed "WinNT://" referenced - does
that need to correspond to a particular folder name on a particular computer?
thanks
"jwgoerlich@gmail.com" wrote:
> See if the following script fits your needs. Run it from the domain
> controller. For the computers you are auditing, you must have
> Administrator privileges and be able to access the computer's RPC
> ports. The output is tab delimited and can be opened in Excel.
>
> Hope this helps,
>
> J Wolfgang Goerlich
>
>
> Set oADInfo = CreateObject("ADSystemInfo")
> Set oFso = WScript.CreateObject("Scripting.Filesystemobject")
> Set oShell = WScript.CreateObject("Wscript.Shell")
>
> LogPath = oShell.SpecialFolders("MyDocuments") + "\Privileged Local
> User Audit.txt"
> AdsiPath = "WinNT://" + oADInfo.DomainShortName
> tab = Chr(9)
>
> ' Connect to Active Directory
>
> Set ADComputers = GetObject(AdsiPath)
> ADComputers.Filter = Array("Computer")
>
> ' Open the log file
>
> Set oLog = oFso.CreateTextfile(LogPath, true)
> oLog.WriteLine "Privileged Local Users on Computers in the " + _
> oADInfo.DomainDNSName + _
> " domain."
> oLog.WriteLine Now
> oLog.WriteLine ""
> oLog.WriteLine "Computer" + tab + _
> "Administrators" + tab + _
> "Administrators Groups" + tab + _
> "Power Users" + tab + _
> "Power Users Groups"
>
> ' Check each computer
>
> For Each oComputer in ADComputers
>
> ' Trap any errors in case the user is unauthorized, the computer is
> inaccessible, etc.
> On Error Resume Next
>
> ' Get the Administrators users and groups
>
> AdminUsers = ""
> AdminGroups = ""
>
> Set objGroup = GetObject("WinNT://" & oComputer.Name & "/
> Administrators")
> If Not(Err.Number = 0) Then
> AdminUsers = Err.Number
> AdminGroups = Err.Number
> End If
>
> For Each objUser In objGroup.Members
> If objUser.Class = "User" Then
> AdminUsers = AdminUsers + objUser.Name + "; "
> else
> AdminGroups = AdminGroups + objUser.Name + "; "
> end if
> Next
>
> ' Get the Power Users users and groups
>
> PowerUsers = ""
> PowerGroups = ""
> Set objGroup = GetObject("WinNT://" & oComputer.Name & "/Power
> Users")
> If Not(Err.Number = 0) Then
> PowerUsers = Err.Number
> PowerGroups = Err.Number
> End If
>
> For Each objUser In objGroup.Members
> If objUser.Class = "User" Then
> PowerUsers = PowerUsers + objUser.Name + "; "
> else
> PowerGroups = PowerGroups + objUser.Name + "; "
> end if
> Next
>
> ' Output to the log
>
> oLog.WriteLine oComputer.Name + tab + _
> AdminUsers + tab + _
> AdminGroups + tab + _
> PowerUsers + tab + _
> PowerGroups
>
> Next
>
> ' Close log file handle, open the log in Notepad
>
> oLog.Close
> oShell.Run "notepad.exe """ + LogPath + """"
>
> ' Clean up
>
> Set ADComputers = Nothing
> Set oADInfo = Nothing
> Set oFso = Nothing
> Set oLog = Nothing
> Set oLog = Nothing
> Set oShell = Nothing
>
>
|