Announcement

Collapse
No announcement yet.

Script to extract Groups

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script to extract Groups

    HI,

    Looking for a script or tool to extract the AD Groups attributes details such as

    Group type - Universal, Global, Domain Local


    Thanks

  • #2
    Re: Script to extract Groups

    Why not add the Type column to your view in ADUC and right click then select Export to List. This will allow you to create a csv file.

    Comment


    • #3
      Re: Script to extract Groups

      Hi you can extract Group through running command in EMS :

      Get-DistributionGroupMember "<Group Name>" | ft DisplayName

      Comment


      • #4
        Re: Script to extract Groups

        Originally posted by lisa804u View Post
        Hi you can extract Group through running command in EMS :

        Get-DistributionGroupMember "<Group Name>" | ft DisplayName
        Assuming you have Exchange 2007 installed!
        Tom Jones
        MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
        PhD, MSc, FIAP, MIITT
        IT Trainer / Consultant
        Ossian Ltd
        Scotland

        ** Remember to give credit where credit is due and leave reputation points where appropriate **

        Comment


        • #5
          Re: Script to extract Groups

          You could do something like this...just change the echo's to write to a file...

          Code:
           
          
           'http://www.microsoft.com/technet/scriptcenter/resources/qanda/may06/hey0512.mspx
          
           Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &H8
           Const ADS_GROUP_TYPE_SECURITY_ENABLED = &H80000000
           Const ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = &H4
           Const ADS_GROUP_TYPE_GLOBAL_GROUP = &H2
          
           Set objRootDSE = GetObject("LDAP://rootDSE")
           strDNSDomain = objRootDSE.Get("defaultNamingContext")
          
           'Start the ADO connection
           Set objCommand = CreateObject("ADODB.Command")
           Set objConnection = CreateObject("ADODB.Connection")
           objConnection.Provider = "ADsDSOObject"
           objConnection.Open "Active Directory Provider"
           objCommand.ActiveConnection = objConnection
          
           'Set the ADO connection query strings
           StartNode = strDNSDomain
           SearchScope = "subtree"
          
           FilterString = "(objectcategory=group)"
                       	 
           Attributes = "adspath"
          
           'Create the LDAP-Query
           LDAPQuery = "<LDAP://" & StartNode & ">;" & FilterString & ";" _
                      	& Attributes & ";" & SearchScope
          
           objCommand.CommandText = LDAPQuery
           objCommand.Properties("Page Size") = 100
           objCommand.Properties("Timeout") = 30
           objCommand.Properties("Cache Results") = False
          
           Set objRecordSet = objCommand.Execute
          
           If NOT objRecordSet.eof Then
            objRecordSet.MoveFirst
            While Not objRecordset.EOF
          
             Set objGroup = GetObject(objRecordSet.Fields("AdsPath").Value)
          
          	GroupType = objGroup.GetEx("groupType")
          	
          	If GroupType = ADS_GROUP_TYPE_UNIVERSAL_GROUP Then
          	  WScript.echo objGroup.DisplayName & " is a Univerasl Group"
          	End If
          
          	If GroupType = ADS_GROUP_TYPE_SECURITY_ENABLED Then
          	  WScript.echo objGroup.DisplayName & " is a Security Enabled Group"
          	End If
          
          	If GroupType = ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP Then
          	  WScript.echo objGroup.DisplayName & " is a Domain Local Group"
          	End If
          
          	If GroupType = ADS_GROUP_TYPE_GLOBAL_GROUP Then
          	  WScript.echo objGroup.DisplayName & " is a Global Group"
          	End If
          
              Set objGroup = Nothing
              objRecordSet.MoveNext
            Wend
           End If
          
          
          msgbox "Done!"
          WScript.Quit
          Last edited by ekrengel; 27th October 2008, 15:23.

          Comment

          Working...
          X