+ Post New Thread
Results 1 to 8 of 8
Cloud Services Thread, Bulk change Office 365 user names using Powershell? in Technical; Is it possible to bulk change user names using powershell? At the moment, user names are in the format asmith@school.onmicrosoft.com ...
  1. #1

    Join Date
    Apr 2007
    Location
    Croydon
    Posts
    501
    Thank Post
    18
    Thanked 31 Times in 30 Posts
    Rep Power
    22

    Bulk change Office 365 user names using Powershell?

    Is it possible to bulk change user names using powershell?

    At the moment, user names are in the format asmith@school.onmicrosoft.com and we have now purchased and verified our own domain and wish to change user names to the format asmith@domain.com

    I know it can be done manually but this isn't an option as we have 2000 users to change.

    Everything is sync'd with our on-premises AD using DirSync.


    Any ideas?

  2. #2

    Join Date
    Jan 2013
    Location
    Romford
    Posts
    174
    Thank Post
    61
    Thanked 34 Times in 27 Posts
    Rep Power
    9
    Office 365 PowerShell Tip: Bulk change UPN’s | MigrationWiz Blog

    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 | Where { -Not $_.UserPrincipalName.ToLower().StartsWith(“admin@” ) } | ForEach { Set-MsolUserPrincipalName -ObjectId $_.ObjectId -NewUserPrincipalName ($_.UserPrincipalName.Split(“@”)[0] + “@example.com”) }

  3. Thanks to TomCollins from:

    adamf (9th July 2013)

  4. #3

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,148
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    Is there a bulk command to add an additional email address? So we can keep aa@aa.com but also add aa@bb.com to their account (a bb.com email) as we use multiple domains?

    Hopefully that makes sense!

  5. #4

    Join Date
    Apr 2007
    Location
    Croydon
    Posts
    501
    Thank Post
    18
    Thanked 31 Times in 30 Posts
    Rep Power
    22
    I would imagine so...I am working on something now because all the test e-mails I've sent come from the @school.onmicrosoft.com and I want them to come from @domain.com

    If you can change the addresses, I don't see why you can't add more

  6. #5

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,148
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    I'm sure you can, I just wondered if anyone knows the command off hand before I go on a wild hunt online.

  7. #6

    Join Date
    Apr 2007
    Location
    Croydon
    Posts
    501
    Thank Post
    18
    Thanked 31 Times in 30 Posts
    Rep Power
    22
    If you are syncing with your on-premises AD then maybe not... I just got this error:

    The operation on mailbox "username" failed because it's out of the current user's write scope. The action
    'Set-Mailbox', 'EmailAddresses', can't be performed on the object 'username' because the object is being synchronized
    from your on-premises organization. This action should be performed on the object in your on-premises organization.

  8. #7
    Marshall_IT's Avatar
    Join Date
    Jul 2011
    Location
    Leeds
    Posts
    501
    Thank Post
    76
    Thanked 62 Times in 53 Posts
    Blog Entries
    1
    Rep Power
    19
    I believe you need to connect to the exchange Powershell

    Https://outlook. Com/Powershell (I think) there should be instructions find easily.

    The use set-mailbox -identity <user identity> -emailaddresses aa@aa.com, aa@bb.com"

    That should set aa@aa.com as the primary address and aa@bb.com as the secondary.

    You can also add SMTP: in front of the address you want as primary.

  9. #8

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,148
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    Quote Originally Posted by adamf View Post
    If you are syncing with your on-premises AD then maybe not... I just got this error:

    The operation on mailbox "username" failed because it's out of the current user's write scope. The action
    'Set-Mailbox', 'EmailAddresses', can't be performed on the object 'username' because the object is being synchronized
    from your on-premises organization. This action should be performed on the object in your on-premises organization.
    You need to set it within their account in AD. I think this is what you're looking for.

    You can't assign a federated domain to a user in the Office 365 portal

SHARE:
+ Post New Thread

Similar Threads

  1. Office 365 Useful Powershell
    By sottonk in forum Cloud Services
    Replies: 2
    Last Post: 8th March 2013, 01:54 PM
  2. Office 365 - "Display Names" attribute
    By mattpant in forum Cloud Services
    Replies: 1
    Last Post: 19th November 2012, 07:52 PM
  3. Bulk User Creation using Powershell
    By JMBates in forum Windows Server 2008 R2
    Replies: 9
    Last Post: 13th November 2012, 04:26 PM
  4. (Bulk) Change user passwords using csv
    By PEO in forum Windows Server 2008
    Replies: 2
    Last Post: 3rd June 2009, 12:50 PM
  5. Bulk Change User Setting
    By bmdixon in forum Windows
    Replies: 13
    Last Post: 11th February 2009, 11:07 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •