Step 6: Connect to Exchange Online

 

All we have to do now is connect to Exchange Online and we’ll be in business: we’ll be able to use a single Windows PowerShell session to manage Office 365, SharePoint Online, Lync Online, and Exchange Online. With that in mind, run this command, which creates a remote Windows PowerShell session with Exchange Online:

$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection

Admittedly, this is a slightly more complicated command than some of the other commands we’ve run. But that’s OK, because you can copy the command and run it exactly as-is, even though there is a URI included in the command: https://outlook.office365.com/powershell-liveid/. However, that URI is always the same, regardless of the name of your domain. Therefore, copy, paste, run: it’s that easy.

Note

Why is the command for connecting to Exchange more complicated than the command to connect to Lync Online? Technically, it’s not: both commands do the exact same thing. However, the Lync Online team created its own cmdlet – New-CsOnlineSession – that hides some of the parameters (like the Authentication and AllowRedirection) used when connecting to Exchange. Instead of requiring you to type that information yourself, the Authentication and AllowRedirection parameters are effectively built into the New-CsOnlineSession cmdlet. You have to type those parameters when connecting to Exchange because Exchange uses the standard New-PsSession cmdlet to connect to Office 365. The disadvantage to that? You have a little more typing to do. The advantage? You don’t have to download and install an Exchange Online module.

When you connect to Exchange Online, you’ll see a warning message similar to this:

WARNING: Your connection has been redirected to the following URI: "https://pod51035psh.outlook.com/powershell-liveid?PSVersion=4.0"

You don’t have to worry about that message either: it simply tells you that Office 365 has authenticated you and pointed your session towards your Office 365 domain. All you have to do now is import this remote session, just like we did with Lync:

Import-PSSession $exchangeSession

And then, if all goes well, you’ll see something similar to this onscreen:

WARNING: The names of some imported commands from the module 'tmp_nweiqjvl.geu' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.

ModuleType Version  Name             ExportedCommands
---------- -------  ----             ----------------
Script     1.0      tmp_nweiqjvl.geu {Add-AvailabilityAddressSpace...

Now try running this command:

Get-AcceptedDomain

In return, you should see information about your Exchange Online domain:

Name            DomainName          DomainType      Default
----            ----------          ----------      -------
litwareinc.com  litwareinc.com      Authoritative   True

If that command succeeds, that means you can now manage all of Office 365 from a single PowerShell session.

And some people think that more is better than less.

Step 7: End Your Windows PowerShell Session

See Also

Connect to Office 365 by using a single Windows PowerShell window