kpu Posted December 10, 2005 Posted December 10, 2005 Although there maybe a better way to code what I'm doing, my code is working correctly. What I'm struggling with is having is I need a good way to format the output file that logs all the Groups of a computer and the members in each group. Here's what the File looks like after it's done: ---------------------- Group: Administrators Administrator Domain Admins ---------------------- Group: Backup Operators ---------------------- Group: Guests Guest ---------------------- Group: Network Configuration Operators ---------------------- Group: Power Users ---------------------- Group: Remote Desktop Users ---------------------- Group: Replicator ---------------------- Group: Users INTERACTIVE Authenticated Users tstuser1 Domain Users ---------------------- Group: HelpServicesGroup ---------------------- Group: __vmware__ __vmware_user__ Here's the code: (I used VAConvert.04 so you will need that if you try to run it.) Dim $colGroups, $objGroup, $strComputer1, $LGAM_file, $objUser #include <array.au3> #include <bk-logfile.au3> #include <File.au3> _ListMembersOfGroups("localhost") Func _ListMembersOfGroups($strComputer1) $colGroups = ObjGet("WinNT://" & $strComputer1 & "") $colGroups.Filter = _ArrayCreate ("group") For $objGroup In $colGroups ;Write Group Info To File $LGAM_file = FileOpen("logfile.txt", 1) If $LGAM_file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf TrayTip("Writing LogFile", $objGroup.Name, 1) FileWriteLine($LGAM_file, "----------------------") FileWriteLine($LGAM_file, "Group: " & $objGroup.Name) FileClose($LGAM_file) For $objUser In $objGroup.Members () ;Write Member Info To File $LGAM_file = FileOpen("logfile.txt", 1) If $LGAM_file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf TrayTip("Writing LogFile", $objUser.Name, 1) FileWriteLine($LGAM_file, $objUser.Name) FileClose($LGAM_file) Next Next EndFunc ;==>_ListMembersOfGroups The main goal here is to query every computer in a domain and find out who is in each local group of the computer. I've already writen the code to query the "Computers" OU in AD and then write all the PC's to a file. So, I'm almost there... I just can't decide how I should do the rest.... Any help would greatly be appreciated. http://www.kpunderground.com
kpu Posted December 11, 2005 Author Posted December 11, 2005 I'd use .ini files to log info.How so and why to an ini? http://www.kpunderground.com
w0uter Posted December 11, 2005 Posted December 11, 2005 becouse of the ini* functions My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
kpu Posted December 11, 2005 Author Posted December 11, 2005 becouse of the ini* functionsI understand the concept of the ini file, but this code has no changes that should be modifed by the user. Could you be a little more detailed? http://www.kpunderground.com
Danny35d Posted December 11, 2005 Posted December 11, 2005 (edited) I believe what they mind instead of using FileWrite() to Logfile.txt use IniWrite() to Logfile.ini and create one ini file that save the information like this: [ComputerName1] Administrators = Administrator|Domain Admins Backup Operators = Guests = Guest Network Configuration Operators = Power Users = Remote Desktop Users = Replicator = Users = INTERACTIVE|Authenticated Users|tstuser1|Domain Users HelpServicesGroup = __vmware__ = __vmware_user__ [ComputerName2] . . . Where the [sECTIONS] are the computername and the KEYS= Are the groups and the VALUES are the users. After you script query the entier domain is easy to use iniRead() to create a full report or just a few computer report or even a report by specific group. Edited December 11, 2005 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
kpu Posted December 11, 2005 Author Posted December 11, 2005 Thanks Danny35, I see what ya all are saying. I could then creat a GUI with a comboox where all the PC's are listed, and then if the PC is selected it could fill in some other fields...hmmm. Any idea's on how to create a report from the INI file..? http://www.kpunderground.com
gamerman2360 Posted December 11, 2005 Posted December 11, 2005 Some conbination of IniReadSectionNames() and IniReadSection()?
Danny35d Posted December 11, 2005 Posted December 11, 2005 kpu glad that I can help.... give this a try: #include <array.au3> _ListMembersOfGroups("localhost") Func _ListMembersOfGroups($strComputer1) Dim $colGroups, $objGroup, $objUser, $UserNames $colGroups = ObjGet("WinNT://" & $strComputer1 & "") $colGroups.Filter = _ArrayCreate ("group") For $objGroup In $colGroups ;Write Group Info To File TrayTip("Writing LogFile", $objGroup.Name, 1) Sleep(1500) For $objUser In $objGroup.Members () ;Write Member Info To File TrayTip("Writing LogFile", $objUser.Name, 1) $UserNames = $UserNames & '|' & $objUser.Name Next $UserNames = StringMid($UserNames, 2) IniWrite('LogFile.ini', $strComputer1, $objGroup.Name, $UserNames) $UserNames = '' Next EndFunc ;==>_ListMembersOfGroups AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
kpu Posted December 11, 2005 Author Posted December 11, 2005 (edited) ..Nevermind. Posted while Danny35d did. Edited December 11, 2005 by kpu http://www.kpunderground.com
kpu Posted December 11, 2005 Author Posted December 11, 2005 kpu glad that I can help.... give this a try: #include <array.au3> _ListMembersOfGroups("localhost") Func _ListMembersOfGroups($strComputer1) Dim $colGroups, $objGroup, $objUser, $UserNames $colGroups = ObjGet("WinNT://" & $strComputer1 & "") $colGroups.Filter = _ArrayCreate ("group") For $objGroup In $colGroups ;Write Group Info To File TrayTip("Writing LogFile", $objGroup.Name, 1) Sleep(1500) For $objUser In $objGroup.Members () ;Write Member Info To File TrayTip("Writing LogFile", $objUser.Name, 1) $UserNames = $UserNames & '|' & $objUser.Name Next $UserNames = StringMid($UserNames, 2) IniWrite('LogFile.ini', $strComputer1, $objGroup.Name, $UserNames) $UserNames = '' Next EndFunc;==>_ListMembersOfGroups Thanks! This should do the trick! http://www.kpunderground.com
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now