Powershell Exchange 2013 Batch question

Posted on 2014-08-24
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

    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

    Perfect thanks

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
    Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
    In this video we show how to create an Address List 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 Organization >> Ad…
    The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now