Book Image

Microsoft Exchange 2010 PowerShell Cookbook

Book Image

Microsoft Exchange 2010 PowerShell Cookbook

Overview of this book

Table of Contents (22 chapters)
Microsoft Exchange 2010 PowerShell Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Managing distribution groups


In many Exchange environments, distribution groups are relied upon heavily and require frequent changes. This recipe will cover the creation of distribution groups and how to add members to groups, which might be useful when performing these tasks interactively in the shell or through automated scripts.

How to do it...

  1. To create a distribution group use the New-DistributionGroup cmdlet:

    New-DistributionGroup -Name Sales
  2. Once the group has been created, adding multiple members can be done easily using a one-liner:

    Get-Mailbox -OrganizationalUnit Sales | 
      Add-DistributionGroupMember -Identity Sales
  3. We can also create distribution groups whose memberships are set dynamically:

    New-DynamicDistributionGroup -Name Accounting `
    -Alias Accounting `
    -IncludedRecipients MailboxUsers,MailContacts `
    -OrganizationalUnit Accounting `
    -ConditionalDepartment accounting,finance `
    -RecipientContainer contoso.com

How it works...

There are two types of distribution groups that can be created...