Step 4: Connect to SharePoint Online

 

Next up: SharePoint Online. Once again, we need to import the correct Windows PowerShell module before we can do anything else. Fortunately, that’s easy to do; just type this command from the Windows PowerShell prompt and then press ENTER:

Import-Module Microsoft.Online.SharePoint.PowerShell

Note

When you do this you will probably see the following error message displayed onscreen:
WARNING: The names of some imported commands from the module 'Microsoft.Online.SharePoint.PowerShell' 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.
You can safely ignore this warning. The message appears because one of the SharePoint Online cmdlets, Upgrade-SPOSite, uses the verb Upgrade in its name; that verb is typically not used in Windows PowerShell cmdlet names. However, this deviation from the naming standard won’t hurt anything, and the cmdlet will run just fine.

In order to connect to SharePoint Online, you need to supply two pieces of information: your credentials, and the URL of your SharePoint admin site. The credentials part is easy: we’ve already stored that in the variable $credential (see Step 2: Create a Windows PowerShell Credentials Object). As for the URL of your admin site, that’s easy enough to determine as well. Suppose your Office 365 domain name is this:

litwareinc.onmicrosoft.com

To determine the admin site URL, do this:

  1. Start by using the prefix https://.

  2. Add the domain host portion of your domain name. For example, if your domain is litwareinc.onmicrosoft.com then your domain host name is litwareinc. If your domain name is contoso.onmicrosoft.com then your domain host name is contoso. Etc., etc.

  3. Add a hyphen (-) followed by admin.sharepoint.com: -admin.sharepoint.com.

In other words:

https:// + litwareinc + -admin.sharepoint.com = https://litwareinc-admin.sharepoint.com

After you’ve constructed the URL you can then use that URL and your credentials object to connect to SharePoint Online. Just call the Connect-SPOService cmdlet, using a command similar to this one:

Connect-SPOService -Url https://litwareinc-admin.sharepoint.com -credential $credential

To verify that the connection has been made, type the following command at the Windows PowerShell prompt and press ENTER:

Get-SPOSite

You should get back a list of all your SharePoint Online sites:

Url                                       Owner          Storage Quota
---                                       -----          -------------
https://litwareinc-public.sharepoint.com/                 1000                                                                                         
https://litwareinc.sharepoint.com/                       1000                                                                                         
https://litwareinc.sharepoint.com/search                 1000       

But here’s the best part: your Office 365 commands (the ones described in Step 3: Connect to Office 365) will still work. (Try running Get-MsolUser and see for yourself.) That means that you can now manage both Office 365 and SharePoint Online from the same instance of Windows PowerShell. And that’s good. But it’s not quite good enough.

Step 5: Connect to Lync Online

See Also

Connect to Office 365 by using a single Windows PowerShell window