Country73 Posted November 21, 2011 Share Posted November 21, 2011 Not sure if someone has already posted something similar to this or not, but this is what I put together a little while back. Hopefully someone else can find use for it. This is just a basic tool I threw together for my team to quickly display members of specific groups in the "Local Users and Groups" for the local workstation or remote workstations in our domain. 1. Inputbox - to provide the workstation name to gather the LOCAL groups. 2. Combobox - to list the groups to select from, to view members of. 3. _ArrayDisaplay - to displays the members On launch it will save the script to @TempDir - GroupMembership_List.au3 (This is mainly for any future updates to the program and to keep the script handy for any troubleshooting.) You will simply supply the current workstation name, or the name of the remote workstation. Fig1 This will create the combo box for you to select the group you wish to see the members of. Fig2 All members will be displayed with the _ArrayDisplay expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=UserGroup.ico #AutoIt3Wrapper_outfile=GroupMembership.EXE #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Comment=Select Machine & Group to view Members #AutoIt3Wrapper_Res_Description=Display Users in Specified Group #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p #AutoIt3Wrapper_Res_LegalCopyright=Country73 - AutoIt Forum #AutoIt3Wrapper_Res_Language=1033 ://////=__= ://////=__=// #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; #include <GUIConstantsEx.au3> #include <ComboConstants.au3> #include <Array.au3> #cs List Local Group Members This will extract the User Accounts listed in the "Local Users and Groups" Created by: Country73 Created on: 04/19/2011 #ce #region - TEMP FILE INSTALLATION - Removed on Exit FileInstall("GroupMembership_List.au3",@TempDir & "\GroupMembership_List.au3",1) #endregion ; #region - OPTIONS - Opt("GUIOnEventMode",1) #endregion ; #region - INPUTBOX - Local $strComputer = InputBox('Group Membership','Supply the workstation name to retrieve Groups:') If $strComputer = "" Then _ExitNow() $strComputer = StringUpper($strComputer) #endregion ; #region - COMBOBOX GUI - $hGui = GUICreate("Group Memberships", 200 , 30) GUISetOnEvent($GUI_EVENT_CLOSE,"_ExitNow") $Combo = GUICtrlCreateCombo("Select Group...", 5, 5, 190, 20, $CBS_DROPDOWNLIST) $sLUA = _ListGroups($strComputer) If $sLUA = "OFFLINE" Then GUICtrlSetData($Combo,"OFFLINE","OFFLINE") Else GUICtrlSetData($Combo,$sLUA, "Select Group...") GUICtrlSetOnEvent($Combo,"_MemberRet") EndIf GUISetState() While 1 Sleep(100) WEnd #endregion ; #region - LIST GROUPS - Func _ListGroups($strComputer) If Ping($strComputer,450) Then Local $colUsers, $sTmp, $Array[1] = ["group"] $colUsers = ObjGet("WinNT://" & $strComputer) If IsObj($colUsers) Then $colUsers.Filter = $Array For $objUser In $colUsers $sTmp &= $objUser.Name & "|" Next EndIf Return StringTrimRight($sTmp, 1) Else Return "OFFLINE" EndIf EndFunc #endregion ; #region - MEMBERSHIP RETURN VALUES - Func _MemberRet() Local $grouplisting[1],$cGroups,$Array[1] = ["group"] Local $GName = GUICtrlRead($Combo) If $GName = "Select Group..." Then Else $cGroups = ObjGet("WinNT://" & $strComputer) If IsObj($cGroups) Then $cGroups.Filter = $Array For $oGroup In $cGroups If $oGroup.Name = $GName Then For $oUser In $oGroup.Members _ArrayAdd($grouplisting,StringUpper($oUser.Name)) Next EndIf Next _ArrayDelete($grouplisting,0) _ArraySort($grouplisting) _ArrayInsert($grouplisting,0,UBound($grouplisting) & ' - ' & $GName) If UBound($grouplisting) >= 1 Then _ArrayDisplay($grouplisting,$strComputer) Else MsgBox(262144,$GName,'No Members Found') EndIf Else MsgBox(262160,$strComputer,'Unable to extract memberships') EndIf EndIf EndFunc #endregion ; #region - EXIT - Remove any temp installs Func _ExitNow() FileDelete(@TempDir & "\GroupMembership_List.au3") Exit EndFunc #endregion ;UserGroup.icoFig1.bmpFig2.bmp If you try to fail and succeed which have you done?AutoIt Forum Search Link to comment Share on other sites More sharing options...
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