Bulk account activations are now available with the latest Microsoft Online Services Migration Tools. If you’re like me performing this in the past was a pain since you had to activate the accounts through the web portal which allowed you to activate only a handful of accounts at a time and collecting the passwords for delivery to the users was excruciating too. We now have a solution!
The PowerShell script below will read in a list of BPOS accounts and activate them in BPOS. The fields you need in the CSV file are the email address, desired password, location and mailbox size. See the BPOS password requirements before establishing a password.
To run this you must have admin privileges in BPOS and you must have the MSOL Migration Tools installed locally. Save this text with a PowerShell extension (i.e. massActivate.ps1) and open a Migration Command Shell and run the command by typing “.massActivate.ps1”. Make sure the paths in the script exist or change them to suit your needs (i.e. “C:Migration” and “C:MigrationScriptLogs”). The input file is assumed to be massActivate.csv. Also, replace the parameter SubscriptionIDs with the value of your BPOS subscription. You can find this value by running this cmdlet:
Get-MSOnlineSubscription
The script might take a while to complete, depending on the number of accounts you are activating so please be patient.
Here’s a sample CSV file format:
name,mail,passwd,location,mbxsize
TestAccount,Testaccount@contoso.com,P@ssw0rd,US,5368709120
# ==============================================================================================
#
# Microsoft PowerShell Source File — Created with SAPIEN Technologies PrimalScript 2009
#
# NAME: massActivate.ps1
#
# AUTHOR: Erik Enger , PointBridge
# DATE : 11/03/2009
#
# COMMENT: Use this script to mass activate BPOS accounts
#
# Note: This script requires the Microsoft Exchange Transporter snapin
# Modify the default PowerShell profile to add the Quest Snap-In
#
# c:windowssystem32windowspowershellv1.0profile.ps1
#
# add-pssnapin Microsoft.Exchange.Transporter
# ==============================================================================================
# Get the login ID for the BPOS admin account
write-host ‘Enter the username for the MS Exchange Online admin (i.e. admin@contoso.com): ‘
$bposlogin = Read-Host
# Get the password for the BPOS admin account in a secure fashion (display * for password)
cls
write-host ‘Enter the password for the MS Exchange Online admin (admin@contoso.com): ‘ -foregroundcolor yellow -BackgroundColor darkmagenta
$bpospwd = read-host -assecurestring
Write-Host
# Form the BPOS encrypted credential information and store it in a variable to be passed to upcoming commands
$bposcred = new-object -typename System.Management.Automation.PSCredential -argumentlist $bposlogin, $bpospwd
Write-Host
write-host “`n`n`n”
# Get number of available licenses
$totalseats=Get-MSOnlineSubscription -Credential $bposcred
$usedseats=Get-MSOnlineSubscription -Credential $bposcred
$freeseats=$totalseats.TotalSeats-$usedseats.UsedSeats
Write-Host “The number of availble seats in your BPOS subscription is: ” $freeseats
# Count number of accounts you’re trying to activate in BPOS
$nCount=import-csv c:migrationmassActivate.csv
$licenseCount=$nCount.count
Write-Host “You are trying to activate ” $licenseCount ” new accounts.”
$nCount=””
Write-Host `n`n
if($licenseCount -gt $freeseats) {
Write-Host “You do not have enough free licenses to activate all of the objects in your input file. Please purchase additional licenses or remove objects from the activation list. This script will now exit.” -foregroundcolor red -BackgroundColor darkmagenta
exit
}
# If there are enough free BPOS licenses, prompt the user to continue with activation process
# Create choices list
$yes = new-Object System.Management.Automation.Host.ChoiceDescription “&Yes”,””
$no = new-Object System.Management.Automation.Host.ChoiceDescription “&No”,””
$choices = [System.Management.Automation.Host.ChoiceDescription[]]($yes,$no)
#Now to prompt the user and get a result
$caption = “Proceed with mass activation…”
$message = “Do you wish to proceed activating these new accounts?”
$result = $host.ui.PromptForChoice($caption,$message,$choices,0)
if($result -eq 0) {
Write-Host “You answered YES. Proceeding with mass activation. You will be notified when it’s complete.”
“************************************************************************************************”
import-csv c:migrationmassActivate.csv | foreach {
## Start a Transcript
$file=”C:MigrationScriptLogs”
$file+= $_.name +”-massActivate.log”
“************************************************************************************************”
Start-Transcript -Path $file -NoClobber:$false
Write-Host “Starting a Migration for:” $_.name
Date
“************************************************************************************************”
Enable-MSOnlineUser -Identity $_.mail -Password $_.passwd -SubscriptionIDs “abcd1234-123a-456b-c789-d123ef0f12e3” -UserLocation $_.location -MailboxQuotaSize:$_.mbxsize -Credential $bposcred -Verbose
## Stop the log
Date
Stop-Transcript
“************************************************************************************************”
write-host `n`n`n
}
# Get final number of available lic
enses
$totalseats=Get-MSOnlineSubscription -Credential $bposcred
$usedseats=Get-MSOnlineSubscription -Credential $bposcred
$freeseats=$totalseats.TotalSeats-$usedseats.UsedSeats
Write-Host “Now the number of available seats in your BPOS subscription is: ” $freeseats
}
if($result -eq 1) {
Write-Host “You answered NO. Exiting script now.”
exit
}