Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Microsoft Exchange Server 2016 PowerShell Cookbook - Fourth Edition

You're reading from  Microsoft Exchange Server 2016 PowerShell Cookbook - Fourth Edition

Product type Book
Published in Jul 2017
Publisher
ISBN-13 9781787126930
Pages 648 pages
Edition 4th Edition
Languages
Authors (3):
Jonas Andersson Jonas Andersson
Profile icon Jonas Andersson
Nuno Mota Nuno Mota
Profile icon Nuno Mota
Mike Pfeiffer Mike Pfeiffer
Profile icon Mike Pfeiffer
View More author details

Table of Contents (17) Chapters

Preface 1. PowerShell Key Concepts 2. Exchange Management Shell Common Tasks 3. Managing Recipients 4. Managing Mailboxes 5. Distribution Groups and Address Lists 6. Mailbox Database Management 7. Managing Client Access 8. Managing Transport Servers 9. Exchange Security 10. Compliance and Audit Logging 11. High Availability 12. Monitoring Exchange Health 13. Integration 14. Scripting with the Exchange Web Services Managed API 15. Common Shell Information 16. Query Syntaxes

Distribution Groups and Address Lists

In this chapter, we will cover the following:

  • Reporting on distribution group membership
  • Adding members to a distribution group from an external file
  • Previewing dynamic distribution group membership
  • Backing up distribution groups membership
  • Excluding hidden recipients from a dynamic distribution group
  • Converting and upgrading distribution groups
  • Allowing managers to modify group permissions
  • Removing disabled users from distribution groups
  • Working with distribution group naming policies
  • Working with distribution group membership approval
  • Creating address lists
  • Exporting address list membership to a CSV file
  • Configuring hierarchical address books

Introduction

In Chapter 3, Managing Recipients we looked at managing recipients, which covered the process of creating and modifying the membership of both regular and dynamic distribution groups. In this chapter, we are going to dive deeper into distribution group management within the Exchange Management Shell. The recipes in this chapter provide solutions to some of the most common distribution group management tasks that can, and sometimes must, be handled from the command-line. Some of the topics we'll cover include the implementation of group naming policies, allowing group managers to modify the memberships of distribution groups, and more. We'll also go over the process of some basic address list management that can be automated through the shell.

Performing some...

Reporting on distribution group membership

One of the common requests you are likely to receive as an Exchange administrator is to generate a report detailing which recipients are members of one or more distribution groups. In this recipe, we'll take a look at how to retrieve this information from the Exchange Management Shell.

How to do it...

To view a list of each distribution group member interactively, use the following code:

foreach($i in Get-DistributionGroup -ResultSize Unlimited) { 
  Get-DistributionGroupMember $i -ResultSize Unlimited |  
    Select-Object @{n="Member";e={$_.Name}}, 
      RecipientType, 
      @{n="Group";e={$i.Name}} 
} 

This will generate a list of Exchange recipients...

Adding members to a distribution group from an external file

When working in large or complex environments, performing bulk operations is the key to efficiency. Using PowerShell core cmdlets such as Get-Content and Import-CSV, we can easily import external data into the shell and use this information to perform bulk operations on hundreds or thousands of objects in a matter of seconds. Obviously, this can vastly speed up the time we spend on routine tasks and greatly increase our efficiency. In this recipe, we'll use these concepts to add members to distribution groups in bulk from a text or CSV file using the Exchange Management Shell.

How to do it...

  1. Create a text file called c:\Scripts\users.txt that lists the recipients...

Previewing dynamic distribution group membership

The concept of the dynamic distribution group was introduced with the initial release of Exchange 2007 and included a new way to create and manage distribution groups. Unlike regular distribution groups whose members are statically defined, a dynamic distribution group determines its members based on a recipient filter. These recipient filters can be very complex, or they can be based on simple conditions, such as including all the users with a common value set for their Company or Department attributes in Active Directory. Since these dynamic groups are based on a query, they do not actually contain group members and, if you want to preview the results of the groups query in the shell you need to use a series of commands. In this recipe, we'll take a look at how to view the membership of dynamic distribution groups in the...

Backing up distribution groups membership

Now we've worked with distribution groups in the earlier recipe, we know the basics of them. Now we want to utilize PowerShell for backing up the distribution groups and the membership. There could be a lot of reasons for this, but a migration is the most likely one I can think of; examples include a cross-forest migration or, from Exchange on-premises to Exchange Online without having the full Exchange Hybrid with synchronizing all objects, and so on.

In this recipe, we will find all distribution groups and their members to extract that information; we will also be able to restore this information.

How to do it...

In this section, we will see the full script for extracting the...

Excluding hidden recipients from a dynamic distribution group

When creating dynamic distribution groups through the Exchange Management Console, you can specify which recipients should be included in the group using a basic set of conditions. If you want to do more advanced filtering, such as excluding hidden recipients, you will need to configure OPATH filters for your dynamic distribution groups through the Exchange Management Shell. In this recipe, you'll learn how to use the shell to create a recipient filter that excludes hidden recipients from dynamic distribution groups.

How to do it...

Let's say that we need to set up a distribution group for our TechSupport department. The following commands can be used...

Converting and upgrading distribution groups

If you, for some reason, haven't upgraded your legacy distribution groups, this recipe is for you because before migrating to Exchange 2010 from Exchange 2003, you may be carrying over several mail-enabled non-universal groups. These groups will still function, but the administration of these objects within the Exchange tools will be limited. In addition, several distribution group features provided by Exchange 2010, 2013, or 2016 will not be enabled for a group until it has been upgraded. If you somehow haven't upgraded your groups before, now's the time. That's why the recipe is included in this book. This recipe covers the process of converting and upgrading these groups within the Exchange Management Shell.

How to...

Allowing managers to modify group permissions

Many organizations like to give specific users rights to manage the membership of designated distribution groups. This has been a common practice for years in previous versions of Exchange. While users have typically modified the memberships of the groups they have rights to from within Outlook, they now have the added capability to manage these groups from the web-based ExchangeControlPanel (ECP). Exchange 2010 introduced a new security model that changed the way you can delegate these rights. In this recipe, we'll take a look at what you need to do in Exchange 2016 to allow managers to modify the memberships of distribution groups.

How to do it...

  1. The first thing you need...

Removing disabled users from distribution groups

A standard practice amongst most organizations when users leave or have been let go is to disable their associated Active Directory user account. This allows an administrator to easily re-enable the account in the event that the user comes back to work, or if someone else needs access to the account. Obviously, this has become a common practice because the process of restoring a deleted Active Directory user account is a much more complex alternative. Additionally, if these user accounts are left mailbox-enabled, you can end up with distribution groups that contain multiple disabled user accounts. This recipe will show you how to remove these disabled accounts using the Exchange Management Shell.

How to do it...

...

Working with distribution group naming policies

Using group naming policies, you can require that the distribution group names in your organization follow a specific naming standard. For instance, you can specify that all distribution group names are prefixed with a certain word and you can block certain words from being used within group names. In this recipe, you'll learn how to work with group naming policies from within the Exchange Management Shell.

How to do it...

To enable a group naming policy for your organization, use the Set-OrganizationConfig cmdlet, as shown next:

    Set-OrganizationConfig -DistributionGroupNamingPolicy `
    "DL_<GroupName>"  
...

Working with distribution group membership approval

You can allow end-users to request distribution group membership through the ECP. Additionally, you can configure your distribution groups so that users can join a group automatically without having to be approved by a group owner. We'll take a look at how to configure these options in this recipe.

How to do it...

To allow end-users to add and remove themselves from a distribution group, you can set the following configuration using the Set-DistributionGroup cmdlet:

    Set-DistributionGroup -Identity CompanyNews `
    -MemberJoinRestriction Open `
    -MemberDepartRestriction Open  

This command will allow any user in the organization to join or leave the CompanyNews...

Creating address lists

Just like dynamic distribution groups, Exchange address lists can be comprised of one or more recipient types and are generated using a recipient filter or using a set of built-in conditions. You can create one or more address list(s), made up of users, contacts, distribution groups, or any other mail-enabled objects in your organization. This recipe will show you how to create an address list using the Exchange Management Shell.

How to do it...

Let's say we need to create an address list for the sales representatives in our organization. We can use the New-AddressList cmdlet to accomplish this, as shown next:

    New-AddressList -Name 'All Sales Users' `
    -RecipientContainer contoso...

Exporting address list membership to a CSV file

When it comes to working with address lists, a common task is exporting the list of members to an external file. In this recipe, we'll take a look at the process of exporting the contents of an address list to a CSV file.

How to do it...

Let's start off with a simple example. The following commands will export the allUsers address list to a CSV file:

$allusers = Get-AddressList "All Users" 
Get-Recipient -RecipientPreviewFilter $allusers.RecipientFilter |  
  Select-Object DisplayName,Database |  
    Export-Csv -Path c:\allusers.csv -NoTypeInformation 

When the command completes, a list of user display names and their associated mailbox databases will be...

Configuring hierarchical address books

The idea with hierarchical address books is that you can give your users the ability to search for recipients based on your organization's structure, HAB versus the Global Address List which only provides a flat view. HAB was introduced back in Exchange 2010 SP1. The configuration can only be done using the Exchange Management Shell, and, in this recipe, we'll take a look at an example of how you can configure this feature in your organization. If you're planning on using Outlook with Exchange 2016, it requires at least Outlook version 2010 with KB2965295 or newer.

How to do it...

  1. It is recommended that you create an OU in Active Directory to store the root HAB objects...
lock icon The rest of the chapter is locked
You have been reading a chapter from
Microsoft Exchange Server 2016 PowerShell Cookbook - Fourth Edition
Published in: Jul 2017 Publisher: ISBN-13: 9781787126930
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}