Home > Office 365 > Office 365 PowerShell Tip: Bulk change UPN’s

Office 365 PowerShell Tip: Bulk change UPN’s


Sometimes you may provision accounts in Office 365 before any sort of domain validation.  In this case, you don’t want to hit up each user account and manually change the UPN one at a time, possibly leading to setting something incorrectly.  We’re going to give you some PowerShell code you can cut and paste to make this change.  This code will effectively:

  1. Change the domain portion of the UPN to the domain of your choice
  2. Not change the UPN of the admin account (we determine this by ignoring any UPN that begins with “admin@”).  Normally you aren’t going to change the admin account UPN to your own domain and will leave it as the onmicrosoft.com address.

Here’s a quick two line PowerShell command you can do to change all of the UPN’s in your account:

  1. Install the Office 365 PowerShell modules
  2. Launch the command shell from the start menu (Start → All Programs → Microsoft Online Services → Microsoft Online Services Module for Windows PowerShell)
  3. Copy and paste the following into the window (replace example.com with your own domain)

Connect-MsolService

Get-MsolUser -all | Where { -Not $_.UserPrincipalName.ToLower().StartsWith(“admin@”) } | ForEach { Set-MsolUserPrincipalName -ObjectId $_.ObjectId -NewUserPrincipalName ($_.UserPrincipalName.Split(“@”)[0] + “@example.com”) }

As you can see, PowerShell is a very powerfull tool to perform bulk operations.

 

Ref: http://blog.bittitan.com/2012/01/24/office-365-powershell-tip-bulk-change-upns/

Advertisements
Categories: Office 365
  1. February 26, 2016 at 3:51 pm

    Mantap bos… dinantikan kembali article-article berikutnya…

    • February 26, 2016 at 8:25 pm

      siap bos, jangan lupa share, commment dan subscribe ya.. wakaka

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: