![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | list all usesr in Domain Admins group Hi All, I am trying to get all members of Domain Admins group. But my script is only showing me members who has UPN set. If the UPN is blank it does not show me the members. Would you please check it and help me to fix the code. Dim strFilename strFilePath = "C:\Documents and Settings\ampaty.ravi\Desktop\Scripts\domaimembers.xlsx" Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True Set objWorkbook = objExcel.Workbooks.Add() objworkbook.SaveAs(strFilepath) 'objExcel.Workbooks.Add intRow = 2 objExcel.Cells(1, 1).Value = "Account NAME" objExcel.Cells(1, 2).Value = "Display Name" strGroupDN = "cn=Domain Admins,cn=Users,dc=eom,dc=dcgov,dc=priv" Set objFSO=CreateObject("Scripting.FileSystemObject") 'MODIFY THE PATH HERE TO SAVE THE REPORT set objGroup = GetObject("LDAP://" & strGroupDN) Wscript.Echo "Script Started!" for each objMember in objGroup.Members objExcel.Cells(intRow, 1).Value = objMember.SAMAccountName objExcel.Cells(intRow, 2).Value = objMember.DisplayName intRow = intRow + 1 next Wscript.Echo "End of script." Regards Shah |
My System Specs![]() |
| | #2 (permalink) |
| | Re: list all usesr in Domain Admins group "R Shah" <raisboss@xxxxxx> wrote in message news:OT9hH9JVJHA.2084@xxxxxx Quote: > Hi All, > > I am trying to get all members of Domain Admins group. But my script is > only showing me members who has UPN set. If the UPN is blank it does not > show me the members. > > Would you please check it and help me to fix the code. > > Dim strFilename > > strFilePath = "C:\Documents and > Settings\ampaty.ravi\Desktop\Scripts\domaimembers.xlsx" > > Set objExcel = CreateObject("Excel.Application") > objExcel.Visible = True > > Set objWorkbook = objExcel.Workbooks.Add() > objworkbook.SaveAs(strFilepath) > 'objExcel.Workbooks.Add > intRow = 2 > > objExcel.Cells(1, 1).Value = "Account NAME" > objExcel.Cells(1, 2).Value = "Display Name" > > > strGroupDN = "cn=Domain Admins,cn=Users,dc=eom,dc=dcgov,dc=priv" > > Set objFSO=CreateObject("Scripting.FileSystemObject") > > 'MODIFY THE PATH HERE TO SAVE THE REPORT > > set objGroup = GetObject("LDAP://" & strGroupDN) > Wscript.Echo "Script Started!" > > for each objMember in objGroup.Members > objExcel.Cells(intRow, 1).Value = objMember.SAMAccountName > objExcel.Cells(intRow, 2).Value = objMember.DisplayName > intRow = intRow + 1 > next > > Wscript.Echo "End of script." > > > Regards > Shah > that have the group designated as their "primary" group. The Members method of the group object never reveals any object that has the group designated as their "Primary" group. Having a value assigned to the userPrincipalName attribute should not be a factor. If for some reason you have designated "Domain Admins" as the "primary" group (not recommended), I have an example VBScript program that documents all members of any domain group, including membership due to group nesting and the "primary" group, linked here: http://www.rlmueller.net/List%20Memb...0a%20Group.htm To retrieve all objects that have a specific group designated as their "primary", bind to the group object and retrieve the value of the "primaryGroupToken" attribute. This attribute is operational (also called constructed), so you must use the GetInfoEx method to force AD to return the value. All objects whose "primaryGroupID" attribute matches this value have the group designated as their "primary". The program linked above use ADO to query AD for all such objects (users or computers). If you are not interested in membership due to group nesting, you can comment out the recursive call in Sub EnumGroup, which is the statement: Call EnumGroup(objMember, strOffset & " ") -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| add a global group to a domain local group | VB Script | |||
| Difference between a domain group and a local group | VB Script | |||
| Full Local Access for Domain Admins | Network & Sharing | |||
| Add domain group to local group question | VB Script | |||
| 2 Domain Admins, 1 Gets Admin Rights, 1 Doesn't | Vista account administration | |||