Creating and Migrating Users via Powershell

by galene at 2012-11-08 18:07:09

Note: This is for provisioning accounts in Office365, so figured I’d post it here in case there’s something specific in O365 account creation and migration compared to normal Exchange or just general file manipulation.


So I’m trying to create and manage my users via powershell. So the first thing I have is just a simple account creation script that takes a CSV, and creates accounts with it using New-MSolUser. Works well so far. The next thing I’m trying to do is create a migration batch for an IMAP server. To do this I need a CSV with EmailAddress,Username,Password. I have all of those things in that initial CSV. The issue is the initial CSV does not have both e-mail address and username. (they’re the same) And it also has a number of unnecessary columns that new-migrationbatch chokes on if it sees.

So how do I take a CSV that has “FirstName,LastName,EmailAddress,DisplayName,Password,Title,Department,Office,OfficePhone,MobilePhone,Fax,Address,City,State,ZIP,Country,License” and get just “EmailAddress,UserName,Password” (Username is a duplicate from EmailAddress) into another CSV file… or otherwise able to be handled by New-MigrationBatch?
by DonJ at 2012-11-09 12:28:58
Import-CSV startingpoint.csv | select -property emailaddress,@{n=‘Username’;e={$_.emailaddress}},password | export-csv newfile.csv