Powershell Scripts for Office 365 Migartion

I am migrating 18 domains from one office365 Tenancy to another.
Let's call them T1 [source] and T2 [destination]. I have migrated smaller domains first to test and have ran into some changes which are fine with only 3-4 users per domain, but when i have 200 user domain migration i will need some automation and good Powershell scripts to help. To date I have gathered a lot of useful scripts, but am not sorely missing the following... Any ideas where or what i can do to get them ?

Remove Vanity domain from any user with it as an alias or Primary domain.#

Bulk Purge all "deleted contacts" or at least bulk delete from CSV.

Assign Vanity domain from CSV, ideally setting as either Primary or Alias.
paologiorgioAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vasil Michev (MVP)Commented:
I think it's better if you do the first part manually, as there are probably too many factors you need to account for. For example, does the user have more than one address, are the secondary aliases in usable format (i.e. will he end up with something like tfdsfhsd@domain.onmicrosoft.com), which one to set up as primary if the primary is removed, etc. You can easily get a list of all the objects that have such aliases, the removal part is what worries me.

 Get-Recipient -Filter {EmailAddresses -like "*domain.com"}

Open in new window


Contacts are 'special case' with WAAD, you can only list them by using objectId or searchstring. If you remove them, they dont go to the recycle bin, so can you clarify what you mean by "deleted contacts"? Perhaps the objects in your case are mailusers?

For adding the new alias, probably the easiest way is to run:
Set-Mailbox user@domain.com -WindowsEmailAddress new@newdomain.com

Open in new window


This will add new@newdomain.com alias, make it primary and preserve user@domain.com as secondary. So you can just pass the CSV imported objects to it.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
paologiorgioAuthor Commented:
Vasil,

Thanks for Reply.

By deleted contacts i mean, i deleted the contact asmith@contoso.com in T2 and they were no longer present in contacts in exchange admin. I thought that it was gone for good.

I then went to add the vanity domain contoso.com (recently verified on T2) to the user asmith (a user with a license) and it threw up the error about the name already exists.

I presumed the contacts had not flushed and went about purging contacts. When i searched for mailcontact containing "asmith" i found my culprit, using the unique ID i forced deletion.

I was then able to add domain and turn my contact essentially into a mailbox.
0
Vasil Michev (MVP)Commented:
Hm, maybe you can try deleting it from WAAD instead of EO, using the Remove-MSOLContact cmdlet. Probably when you remove it from Exchange first it waits for replication, thus the delay you experienced.

Edit: just deleted a test contact from WAAD and immediately created another one with the same email address, no issues.

Repeated the same procedure by deleting the contact from EO instead, again no issues after I recreated it. Strange...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Office 365

From novice to tech pro — start learning today.