Announcement

Collapse
No announcement yet.

Simple export list of users from a group.

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

  • Simple export list of users from a group.

    Hi,

    For several days now I'm trying to find out how to make a simple export of the users from a certain group.

    I've tried making a query in AD Users & Computers but the queries always end up empty.

    I just need a simple list of users seperated by the groups they are in so they can see what their username is. That's the only info I need to see.

    Why this is so hard is beyond me but I'm out of ideas. So does anyone know how to do this?

    Thanks,

  • #2
    Re: Simple export list of users from a group.

    I'm not clear on what their group membership has to do with their username. The username doesn't change based on group membership. Are you just looking to get a list of all usernamess or are you trying to get a list of all usernamess and their group memberships?

    Comment


    • #3
      Re: Simple export list of users from a group.

      Originally posted by joeqwerty View Post
      I'm not clear on what their group membership has to do with their username. The username doesn't change based on group membership. Are you just looking to get a list of all usernamess or are you trying to get a list of all usernamess and their group memberships?
      I'm doing this for a school. Every teacher has to have a list of all the usernames of the students in their class. The classes are the groups. So I only need a list of usernames per class / group.

      Comment


      • #4
        Re: Simple export list of users from a group.

        I think you might be getting a bit confused.
        Usernames are an attribute (-sAMAccountName or -userPrincipalName) of a user object that is stored in a container (Typically a OU).
        Group membership is also an attribute of the User object (-memberOf)
        Now, although by querying AD for a specific value of the -memberOf attribute such as the group you need might return the same results, i think it is better if you create separate OU for each class and store the user objects in there.
        Then all you need to do from ADUC is R click on the OU and export the list of objects to a txt file or whatever.

        Cheers
        Caesar's cipher - 3

        ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

        SFX JNRS FC U6 MNGR

        Comment


        • #5
          Re: Simple export list of users from a group.

          Originally posted by L4ndy View Post
          I think you might be getting a bit confused.
          Usernames are an attribute (-sAMAccountName or -userPrincipalName) of a user object that is stored in a container (Typically a OU).
          Group membership is also an attribute of the User object (-memberOf)
          Now, although by querying AD for a specific value of the -memberOf attribute such as the group you need might return the same results, i think it is better if you create separate OU for each class and store the user objects in there.
          Then all you need to do from ADUC is R click on the OU and export the list of objects to a txt file or whatever.

          Cheers
          That's a bit too late now haha. Changing the setup of AD would take too much time. Everything work perfectly, I just need a list of usernames from a specific group.

          Working with Windows Server really openend my eyes on how trivial things can take load of time haha.

          Comment


          • #6
            Re: Simple export list of users from a group.

            I am using this:

            Const Formyfile = 1
            on error resume next
            Set con = CreateObject("ADODB.Connection")
            Set com = CreateObject("ADODB.Command")
            Set rsset = CreateObject("ADODB.recordset")
            con.Provider = "ADsDSOObject"
            con.Open "Active Directory Provider"
            com.ActiveConnection = con
            com.Properties("searchscope") = 2
            com.Properties("Page Size") = 100000
            Set fso = CreateObject("Scripting.FileSystemObject")
            Set os = fso.CreateTextFile(".\Output.txt")
            Set ts = fso.OpenTextFile(".\Input.txt",formyfile,True)

            do While Not ts.AtEndOfStream
            strUsersID = Trim(ts.ReadLine)
            'Wscript.Echo strUsersID
            strQuery = "<LDAP://dc=Microsoft,dc=com>;(&(objectclass=group)(cn=" & strUsersID & "));member"
            Com.CommandText = strQuery
            Set rsset = com.Execute
            Members = rsset.Fields("member")
            For Each objGroup in Members
            Set objtest = GetObject("LDAP://" & objGroup)
            os.WriteLine objtest.displayName &" ("& objtest.cn &")"
            Next

            loop
            Wscript.Echo "done"
            Kapil Sharma
            ~~~~~~~~~~~~~
            Life is too short, Enjoy It.

            Comment


            • #7
              Re: Simple export list of users from a group.

              Also need to do the following:

              1. Change the domain name highlighted in bold red.
              2. Create a input.txt file and write the name of group/s in that.
              Kapil Sharma
              ~~~~~~~~~~~~~
              Life is too short, Enjoy It.

              Comment

              Working...
              X