locked
Conditional Add member to specific Distribution Group RRS feed

  • Question

  • Helllo All,

    I would like to add user to specific distribution group ,for example if user's department is Sales it should member of Sales Distribution group if not  it should member of accounted Distribution group

    how can I do this from power shell ,can you help for this? thanks in advance.

    Thursday, October 11, 2012 6:51 AM

Answers

  • You can use command like this to do that:

    Get-User -RecipientType UserMailbox -Filter "Department -like 'Sales Department'"| foreach{ add-distributiongroupmember -identity "Sales group" -member $_.name}

    Thanks,

    Evan


    Evan Liu

    TechNet Community Support

    Sunday, October 28, 2012 12:01 PM
    Moderator

All replies

  • Hi Mscik,

    I assume you use Exchange 2010.

    Why not using the 'Dynamic distribution group'?

    it should look something like :

    new-DynamicDistributionGroup -Name 'Sales Department' -IncludedRecipients 'MailboxUsers, Resources, MailUsers' -ConditionalDepartment 'Sales' -Alias 'SalesDepartment'

    As soon as the Department field is filed with "Sales" the recipient will be member of this group

    Thursday, October 11, 2012 7:25 AM
  • Hi Kees,

    thank you for your answer,I don't want to use DynamicDistributionGroup because,scenario is that;

    resigned personel  mailbox are archiving by Symantec EV,there are 2 profile in EV and both of them have different settings,EV profile work by distribution group so after resign I have to add suitable group to user,but I want to do this by automatickly,thats why  I  need to do this in distribution group ,not in Dyn.group :(

    Thursday, October 11, 2012 10:12 AM
  • Hi,

    Distribution group will never get added by itself. You have to do it manually if you don't want to use dynamic distribution group. 


    Kottees : My Blog : Please mark it as an answer if it really helps you.

    Thursday, October 11, 2012 2:05 PM
  • Hi imkottees,

    I think this is not related kind of group because it can be in power shell

    Friday, October 12, 2012 5:21 AM
  • You can use command like this to do that:

    Get-User -RecipientType UserMailbox -Filter "Department -like 'Sales Department'"| foreach{ add-distributiongroupmember -identity "Sales group" -member $_.name}

    Thanks,

    Evan


    Evan Liu

    TechNet Community Support

    Sunday, October 28, 2012 12:01 PM
    Moderator