One working on large or complex environments performing bulk operations is the key to efficiency use
and power schelde core common glass such as gut content which you have already mentioned and importances
feet.
We can easily import external data into the shell and to use this information to perform Baul corporations
on hundreds or thousands of objects in a matter of seconds.
Obviously we can want to speed up the time spent on routine tasks and greatly increase our efficiency.
And this video will use these concepts to add members to distribution groups in bulk from a text or
a file using the Exchange management shell to start off let's create a text file called users dot text
me I'll create it on a C drive root.
This file will list the recipients in your organization that you want to add to a group.
Make sure you answer them one line at a time.
Next up we have to run the following code to add the list of recipients to a distribution group real
time.
Get content.
The path to our file.
In my case it's siecle backslash.
Users don't text and pipe the results to for each object command left and as a result each object which
is contained in our file will be added to sales distribution group with the ADD distribution group member
command left.
When the code runs each user loose to tell the users that txt file will be added to the sales distribution
group when important data from a plain text file we use to get content command left which will read
the content of the file into the shell one line at a time.
In this example we pipe the content of the file to the foreach object command left and as each line
is processed we run the ADD distribution group command let inside the foreach object script block.
We're there at distribution group member command left and to sign the dollar sign on the bar or object
which is the current recipient item in the pipeline to the member parameter.
Please know that to remove recipients from a distribution group you can use the remove distribution
group member command lead.
Now keep in mind that this text file does not have to contain the S.M. to be address of the recipient.
You can also use the active directory called Name use or principal name distinguished name Greta or
legacy change.
DN Well here's the important thing that the file contains.
Well it and to unique Well your foreach recipient.
If the identity of the recipient cannot be determined the distribution group member command will fail.
In addition to use an plain text files we can also import recipients from a CSP file and add them to
a distribution group.
Let's say that you have a CSP file set up with multiple columns such as first name last name and email
address.
When you import this history file the data can be accessed using the goal and headers of the property
names for each object.
In this case we have to use imports since the command left.
So when you do each item in the collection of an email address like in my file.
Users don't see this field as long as this information corresponds to the recipient data in the exchange
organization.
We can simply loop through each record to see as we file and add this recipients to a distribution group.
Take a look at this code we are using an import says siecle on backslash users Dud's seriously and pipe
it to for each object we use add distribution group mamber we are adding each object to sales distribution
group and sorting out all this information by email address calling.