How to use PowerShell to add sub domain to Office 365 Online Portal


Summary

This article describe a straightforward way to use PowerShell to add sub domain to Office 365 Online Portal

How implement these steps:

1.       Download and install the Microsoft Online Services Module for Windows PowerShell (new version):

Microsoft Online Services Module for Windows PowerShell 32-bit

Microsoft Online Services Module for Windows PowerShell 64-bit

2.       Create a new remote PowerShell connection against the PowerShell endpoint for Office 365:

Import-Module msonline
$cred = Get-Credential
Connect-MsolService -cred $cred
Get-Command *msol*

3.       Add domain to MS Online Services by using below commands:

Set-MSOLContextCredential –MSOLadminCrendentials (get-credential)
Add-MSOLFederatedDomain –DomainName <string>

     

    More Information

    Install and Configure Windows PowerShell

    http://help.outlook.com/en-us/140/cc952756.aspx

     

    Applies To

    Microsoft Office 365 for Enterprise

     

     

     

    Comments (7)

    1. NADEEM says:

      Hi, I'm aware that Sub-Domain capability is not available in Plan P1, but can you tell me whether Sub Domains are available with the Academic Plans?.

      Thanks…..

    2. KB author says:

      Hi Nadeem,

      Sub Domains are still available with Academic plan, You can manage your domains from:

      http://domains.live.com/

    3. FMustafa says:

      Small correction to the command:

      New-MSOLFederatedDomain –DomainName <string>

      There is no Add-MSOLFederatedDomain options.

      Thanks!

    4. Philip says:

      Links are broken.

    5. Newclique says:

      Please add the link to the Microsoft Online Services Sign-in Assistant to this page. It will help users who get the error when they try to install the Microsoft Online Services Module.

    6. Anonymous says:

      How to use PowerShell to add sub domain to Office 365 Online Portal – The Hot Blog – Site Home – TechNet Blogs

    7. Hi,

      acccording to the ‘important’ section of the followinf page :
      https://msdn.microsoft.com/library/azure/jj205461.aspx?f=255&MSPPError=-2147217396

      it is said that :
      "If you are using a subdomain (for example, corp.contoso.com) in addition to a top-level domain (for example, contoso.com), you must add the top-level domain in your cloud service before you add any subdomains. When the top-level domain is set up for single
      sign-on, all subdomains are automatically set up as well"

      According to that page, there is no action required for the child domains once the parent is set up for SSO

      Am I missing something ?

      Currently have a validated (o365/Azure validated) domain (parent domain) wich is onprem "contoso.net"
      The need is to connect also the "abc.contoso.net" users to o365 :
      – ADConnect connector syncs well the onprem accounts to o365
      – but the o365 login fails with following message
      AADSTS50107: Requested federation realm object ‘http://abc.contoso.net/adfs/services/trust/‘ does not exist.

      Thanks.