How to provision Recipients in Bulk in Exchange Server with PowerShell

Home > Blogs > Exchange Server > How to provision Recipients in Bulk in Exchange Server with PowerShell

How to provision Recipients in Bulk in Exchange Server with PowerShell

Like This Blog 0Mike Pfeiffer
Added by September 18, 2013

When it comes to provisioning users in bulk there’s a couple of common things typically people are reading data out of text file, reading it out of a CSV file or basically just pulling out of Active Directory. Let’s take a look out of the AD scenario.

If I use:

Get-User –RecipientTypeDetails user

These are just the plain old users, those are all people out there in AD that do not have mailboxes.

001-AD-Provision-Recipients-in-Bulk

So if I want to do this in bulk I could just pipe this over to another command and create these mailboxes.

In that case you would have a script that would run, maybe the AD guys are responsible for provisioning Active Directory user accounts and your job is only to create the mailboxes. Maybe once a week you could go out and scan on a certain OU and create mailboxes from there.

You could use:

Get-User –RecipientTypeDetails user –OrganizationalUnit sales

002-OU-AD-Provision-Recipients-in-Bulk

I’ve got four sales user out there that don’t have mailboxes and I could continue piping that over to enable mailbox

Get-User –RecipientTypeDetails user –OrganizationalUnit sales | Enabel-Mailbox

What will happen is, it will create all of those four mailboxes for me in one shot.

003-OU-AD-Provision-Recipients-in-Bulk

That’s kind of one method you could use to bulk provision users.

Another method would be from a CSV file. We have the ability to do this from any kind of external file, but the most common use for this is a CSV. The reason is because it allows you to define multiple settings.

For example, in this file I’ve only got three properties‑‑name, alias and user principle name.

You may also like:  Methods to Enable and Disable Remote Desktop Locally

004-csv-file-Provision-Recipients-in-Bulk

But you could populate this with multiple columns for all kinds of different settings.

Basically you just read this in. Loop through each row in the CSV and pass these details into the cmdlet parameters as needed.

Reading this data into the shell, CSV file is as simple as doing an import CSV.

005-csv-file-Provision-Recipients-in-Bulk

You could see there that the whole CSV gets pulled into the shell. As I loop through each one of these records I can access each individual property name.

For example, if I pipe these before each object, the dollar sign underscore would represent each row as it kind of passes over the pipeline and you can access the column headers using the dot notation.alias for example.

Here are all the aliases.

006-csv-file-Provision-Recipients-in-Bulk

Here’s all the names.

007-name-csv-file-Provision-Recipients-in-Bulk

While you’re inside this script lock {   } you can access all of those properties and kind of pass them into the command.

Let me clear this and start from scratch. What I want to do first is actually create a password and really what I want to do here is show you this in ISE so it’s a little easier to read.

I’m going to do an import CSV, grab the users .csv and pipe that over before each object.

008-name-csv-file-Provision-Recipients-in-Bulk

So first of all I need to create that secure string password object so I’m going to do a new mailbox because these users don’t exist in AD so I’m going to do a $password as follows:

009-name-csv-file-Provision-Recipients-in-Bulk

So it’s going to be a common password assigned to all of these new users.

I’m going to do a new -mailbox. I will assign the name property to the name parameter, the alias to the alias and user principle name. Finally they’re all going to have the same common password.

You may also like:  Using PowerShell to convert to the MiniShell on a Server 2012 R2 Datacenter Core Edition

010-name-csv-file-Provision-Recipients-in-Bulk

Since they all have the same common password, I want to do a reset password on next logon, $true.

011-csv-file-Provision-Recipients-in-Bulk

You see that I’m kind of running off to the right of the screen here, getting hard to read. New mailbox actually has I think somewhere between 50 and a hundred parameters, so in theory you could run through this and continue scrolling right for a really long time. If you want to break this up a little bit, you can use PowerShell’s line continuation character which is the back tick [ ` ].

012-csv-file-Provision-Recipients-in-Bulk

So just like this you could break this command up.

013-break-up-command-csv-file-Provision-Recipients-in-Bulk

That’s a little bit easier to read.

Let me go ahead and run this. Bring the output pane up so we could see. Go ahead and test this code. Hit start and there it goes creating all the mailboxes for me that I’m passing those values in straight from the CSV file.

014-runbreak-up-command-csv-file-Provision-Recipients-in-Bulk

That’s just a couple of quick ways you can bulk provision recipients and of course you can use the get content cmdlet as well to read data in from a text file.

 

Videos You May Like

Agile Methodology in Project Management

0 73 0

In this video, you will gain an understanding of Agile and Scrum Master Certification terminologies and concepts to help you make better decisions in your Project Management capabilities. Whether you’re a developer looking to obtain an Agile or Scrum Master Certification, or you’re a Project Manager/Product Owner who is attempting to get your product or … Continue reading Agile Methodology in Project Management

Creating Users and Managing Passwords in Microsoft Office 365

0 163 1

In this Office 365 training video, instructor Spike Xavier demonstrates how to create users and manage passwords in Office 365.

Detailed Forensic Investigation of Malware Infections – April 21, 2015

2 266 3

In this IT Security training video, Security expert Mike Danseglio (CISSP / CEH) will perform several malware investigations including rootkits, botnets, viruses, and browser toolbars.

Write a Comment

Share your thoughts...

Please fill out the comment form below to post a reply.