Book Image

Microsoft Exchange Server Powershell Cookbook (Update)

Book Image

Microsoft Exchange Server Powershell Cookbook (Update)

Overview of this book

Table of Contents (21 chapters)
Microsoft Exchange Server PowerShell Cookbook Third Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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. By 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 reduce 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...

Let's see how to add members to a distribution group from an external file using the following steps:

  1. Create a text file called c:\Scripts\users.txt that lists the recipients in your organization that you want to add to a group. Make sure you enter them one line at a time, as shown in the following screenshot:

  2. Next, execute the following code...