Learn how to a build a cloud-first strategyRegister Now


Powershell Exchange 2013 Batch question

Posted on 2014-08-24
Medium Priority
Last Modified: 2014-08-26
I work in a very large enterprise environment and we are moving users to Exchange 2013. The one issue that we need to automate is placing the primarysmtpaddress in a text file with the header emailaddress. What we have done is taken a large mass of users maybe 1,000 at a time and save them to different csv files with the header emailaddress. In the CSV file/excel we sort by name and create a column called batch. In there we place numbers 1-30 and keep starting over from 1-30 until we get to the 1,000th person. We then sort on that field and everything with 1 goes into a file with emailaddress as the header and populate this with just the primarysmtpaddress.We do this for everything that has a number 2, place this in a csv file with the header emailaddress with the primarysmtpaddress. We keep going on and on and on until we reach 30th which has the 1000 user. As you can see this is painful and long.  How can you get powershell to look inside of a csv file, grab all the number 1's place them into a separate csv file with the header emailaddress and move on until it gets to 30.  If someone has a better method please do share
Question by:techdrive
LVL 40

Accepted Solution

Subsun earned 2000 total points
ID: 40282262
If i understand your requirement, then the following code should do it.. It will take the input file with columns headers "emailaddress" & "batch", then split the csv file like, all batch one will go to batch1.txt, batch two should go to batch2.txt etc..
Import-Csv C:\input.csv | Group Batch | %{
$File = "C:\batchfiles\Batch$($_.Name).txt"
 $_.Group | Select emailaddress | Export-Csv $File -nti

Open in new window

Test and let me know if you need any modifications..

Author Comment

ID: 40286941
Perfect thanks

Featured Post

New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
If you have come across a situation where you need to find some EDB mailbox recovery techniques, then here you will find the same. In this article, we will take you through three techniques using which you will be able to perform EDB recovery. You …
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question