How to provision Recipients in Bulk in Exchange Server with PowerShell
How to provision Recipients in Bulk in Exchange Server with PowerShell
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.
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
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.
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.
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.
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.
Here’s all the names.
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.
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:
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.
Since they all have the same common password, I want to do a reset password on next logon, $true.
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 [ ` ].
So just like this you could break this command up.
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.
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.
You May Also Like
Active Directory, AD, Enable-Mailbox, Exchange Server Provisioning, Get-User, PowerShell Bulk
A Simple Introduction to Cisco CML2
0 3852 0Mark Jacob, Cisco Instructor, presents an introduction to Cisco Modeling Labs 2.0 or CML2.0, an upgrade to Cisco’s VIRL Personal Edition. Mark demonstrates Terminal Emulator access to console, as well as console access from within the CML2.0 product. Hello, I’m Mark Jacob, a Cisco Instructor and Network Instructor at Interface Technical Training. I’ve been using … Continue reading A Simple Introduction to Cisco CML2
Cable Testers and How to Use them in Network Environments
0 713 1This content is from our CompTIA Network + Video Certification Training Course. Start training today! In this video, CompTIA Network + instructor Rick Trader demonstrates how to use cable testers in network environments. Let’s look at some tools that we can use to test our different cables in our environment. Cable Testers Properly Wired Connectivity … Continue reading Cable Testers and How to Use them in Network Environments
Government Edition – Encrypting a USB Flash Drive in Windows 10
0 272 2In this video, Security Instructor Mike Danseglio demonstrates how to use BitLocker in Window 10 to secure files on a USB Flash drive that adhere to stricter data protection requirements as found inside Government entities. BitLocker 2-day instructor-led training is now available at Interface: BITLOCK: Planning and Deploying BitLocker Drive Encryption Training Video Transcription: Hi. … Continue reading Government Edition – Encrypting a USB Flash Drive in Windows 10