locked
Listing Member Of tab RRS feed

  • Question

  • Hi!!

      Is there a way to get the distribution groups that a mailbox is "member of" by Powershell?

    I'm planning to get a profile and copy the groups so I can set them on another mailbox account, I'm sure it's something very common to all of us who had to create mailboxes regularly.

      Thanks in advance!

    Regards

    Balzak

    Friday, March 4, 2011 7:17 PM

Answers

  • The simplest and fastest would be to use build in tools:

    dsquery user -name "krystian*" | dsget user -memberof | dsget group -dn -secgrp

    something like above will display all groups a user is member of with information if this is security group or not

    in PS something like below

    $user = [ADSI]"LDAP://CN=Krystian Zieja,OU=People,DC=projectenvision,DC=com"
    $groups = $user.memberof
    foreach ($group in $groups)
    {
    	$g = [ADSI]"LDAP://$group"
    	# you can filter here using $g.groupType	
    	Write-Host $g.name	
    }
    

    With kind regards
    Krystian Zieja
    http://www.projectnenvision.com
    Follow me on twitter
    My Blog
    • Marked as answer by Serena Li Monday, March 14, 2011 2:33 AM
    Saturday, March 5, 2011 12:30 AM

All replies

  • The simplest and fastest would be to use build in tools:

    dsquery user -name "krystian*" | dsget user -memberof | dsget group -dn -secgrp

    something like above will display all groups a user is member of with information if this is security group or not

    in PS something like below

    $user = [ADSI]"LDAP://CN=Krystian Zieja,OU=People,DC=projectenvision,DC=com"
    $groups = $user.memberof
    foreach ($group in $groups)
    {
    	$g = [ADSI]"LDAP://$group"
    	# you can filter here using $g.groupType	
    	Write-Host $g.name	
    }
    

    With kind regards
    Krystian Zieja
    http://www.projectnenvision.com
    Follow me on twitter
    My Blog
    • Marked as answer by Serena Li Monday, March 14, 2011 2:33 AM
    Saturday, March 5, 2011 12:30 AM
  • Thanks!! It Worked very well...

      Didn't had time to aswer early cause I went out on vacation.

     

    Thank you again!!

     

    Regards

    Monday, March 14, 2011 2:13 PM