Sign in to follow this  
Followers 0
kpu

Idea's needed

11 posts in this topic

Although there maybe a better way to code what I'm doing, my code is working correctly. :lmao: 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. :P

Share this post


Link to post
Share on other sites



I'd use .ini files to log info.

Share this post


Link to post
Share on other sites

becouse of the ini* functions

I 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?

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by Danny35d

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

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..? :P

Share this post


Link to post
Share on other sites

Some conbination of IniReadSectionNames() and IniReadSection()?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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! :P

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0