Unable to export mail ID's from security group

This topic contains 2 replies, has 2 voices, and was last updated by  Shashank 2 years, 6 months ago.

  • Author
  • #33148


    Hi Guys,

    I am trying to export the email ID's from security group with the below command:

    Command :dsget.exe group "CN=Test Team,CN=Users,DC=ABC,DC=testbed,DC=com" -members| dsget user -email

    The above command works out well but only when the security group contains domain ID's with exchange mailboxes.

    Now if I use the same command to export the email ID's of security group which contains mail contact; it gives me the the below error:
    dsget failed:CN=Test User,CN=Users,DC=ABC,DC=testbed,DC=com:The object class of the target does not match the one specified on the command line.

    dsget user is looking for domain user and not the mail contact hence the above error.

    Command : I tried another command get-adgroupmember -identity "Test Team" but since the group contains more than 10,000 objects (domain ID and mail contact) it returned me
    the below error message:
    Get-ADGroupMember : The size limit for this request was exceeded

    To summarize, I just need a command to pull out the email ID's from security group which contains domain users alongwith the contacts.

    I am running these commands in test environment before running them on production environment.
    Let me know if any more details are needed.

  • #33151

    Matt Bloomfield

    From testing here, I don't think get Get-ADGroupMember will work either. That command only returns groups, users and computers, and a contact object is a separate class of object. Try the Get-ADObject command with an LDAP filter on the group's DN. You can use the ResultSetSize parameter to ensure all objects are returned.

    Get-ADobject -LDAPFilter '(memberOf=CN=Test Team,CN=Users,DC=Contoso,DC=Com)' -ResultSetSize $null -Property mail | Select-Object mail
  • #33152


    Perfect Matt !!!!!
    Thanks a lot.

You must be logged in to reply to this topic.