Office 365 – Adding a Domain with PowerShell

PowerShell is cool. I don’t quite understand how it all works just yet, I am still learning PowerShell. Here is some quick advice before we move on, don’t fall in love with a cmdlet because they have been known to disappear from time to time. Having said all that PowerShell is extremely powerful for managing your Office 365 environment. I have been focusing on PowerShell basics lately, and how to get going with Office 365. In this blog I’d like to cover how to connect to Office 365 and add a domain using strictly PowerShell. In a few previous blogs, I performed these same things through the GUI

http://365unity.com/?p=60 and http://365unity.com/?p=96

First off before you can use the Office 365 cmdlets there are a few requirements you must meet.

Software Requirements

  • You must be running Windows 7, Windows 8 or Windows 8.1
  • .Net Framework 3.5.1 Should be installed
  • The Microsoft Online Assistant should be installed (http://www.microsoft.com/en-ca/download/details.aspx?id=28177)
    • This software sits in the background and assists with logging Lync and Outlook onto Office 365
  • Windows Azure Active Directory Module for Windows PowerShell (https://bposast.vo.msecnd.net/MSOPMW/Current/amd64/AdministrationConfig-en.msi)

If you struggled with the last step and wanted to yank out your hair because you were sure you installed the right version of Microsoft Online Assistant. Read this

http://blogs.technet.com/b/tune_in_to_windows_intune/archive/2013/11/09/error-when-trying-to-install-windows-azure-active-directory-module-for-windows-powershell.aspx

You need to install the Microsoft Online Assistant Services Sign-In Assistant Beta (http://www.microsoft.com/en-my/download/details.aspx?id=39267)…They have not fixed this in over a year, I am not sure why.

Once the Beta version of Sign-In Assistant is installed you can install the Azure Active Directory Module for PowerShell. Once installed we’re ready to connect to Office 365 via PowerShell

Connecting to Office 365

The first thing we are going to do is run the Windows Azure Active Directory Module for Windows PowerShell

The first PowerShell cmdlet we are going to use here is on that will allow us to connect to the domain

connect-msolservice

Connect-MSOLSERVICE

When it connects successfully, we will not see a confirmation. To validate if you are in properly you can run a cmdlet such as

get-msoldomain and it should return at least your company.onmicrosoft.com

get-msoldomain

Perfect, we’ve validated that we’ve connected to Office 365 via PowerShell.

Add a Domain to Office 365 via PowerShell

Now we are going to add our domain to Office 365. If you’ve read my other blogs, there are 4 steps to adding a domain and through PowerShell it’s no different

  1. Add Domain
  2. Get Verification DNS record
  3. Add DNS record to DNS provider
  4. Validate ownership of the domain

Firstly we are going to add the domain

New-MSOLDomain -Authentication Managed -Name 365unity.com

NEW-MSOLDOMAIN

You will notice that the Status is set to unverified. This will be fixed in the next two commands.

Get-MSOLDomainVerificationDNS -domainname 365unity.com -Mode DNSTxtRecord (You could also use DNSMxRecord here, but TXT is easiest)

Get-validation

Copy the DNS TXT record info and create the record with the DNS provider hosting your domain name, in my case it’s GoDaddy.

TXTrecrod

Now we can confirm that we own the domain, this step may take up to an hour depending on your TTL setting.

Confirm-MSOLDomain -DomainName 365unity.com

and we should get a successfully validated message.

domainvalidated

Now to make sure that it works, we can run Get-MSOLDomain and we should see that its status changed to verified

domainverified

What I really like about PowerShell is that it skips all of the wizards and let’s you do what you want to do. What can be intimidating about it is you may not know all of the commands available to you. I am often using tab to run through all of the possible commands based on a first few letters.

12 Comments

  1. mcqyhhjnnhd

    yyzhnda

    arx

  2. I have been surfing online more than 3 hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. Personally, if all website owners and bloggers made good content as you did, the net will be much more useful than ever before.
    [url=http://decoration66.com/index.php/component/k2/item/13-uisque-ac-gravida-ligula-nunc-nisi/contact.php?cache=yeserror=DIFFERENT_DOMAINback=http%3A%2F%2Fwww.fingersporn.top%2F]lindseyml[/url]

  3. Good means of telling, and pleasant post to get information concerning my presentation subject,
    which i will deliver in institution of higher education.

  4. I am just actually happy to read this webpage posts which includes
    lots of useful facts, thanks for providing such statistics.

  5. This design is wicked! You obviously understand how to have
    a reader entertained. Between wit as well as
    your videos, I found myself almost transferred to start my own, personal blog (well, almost…HaHa!) Excellent job.

    I really enjoyed whatever you was required to say, and more
    than that, how you will presented it. Too cool!

  6. What’s up, all is going fine here and ofcourse every one is sharing information, that’s truly fine, keep up writing.

  7. Hey there would you mind sharing which blog platform you’re working with? I’m looking to start my own blog in the near future but I’m having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design seems different then most blogs and I’m looking for something completely unique. P.S Sorry for getting off-topic but I had to ask!

  8. Awesome! This may be one of the most useful things on the topic I’ve ever read. Many thanks for your effort.
    http://cuanhomnhatban.com/help-me-write-my-term-paper/best-admission-essays-the-right-way-to-enter-into/

  9. Awesome! This can be by far the most useful thing on the subject I’ve ever found. Thank you for your hard work.
    http://globalhseconsult.com/custom-essay-writing-order-your-essay-today-1199-2/

  10. Many thanks for the blog, it’s packed with a lot of handy information. This helped me a lot.
    http://www.pasalis-apartments.gr/the-plan-of-our-custom-writing-service-would-be-to/

Leave a comment

Your email address will not be published.


*