Connecting PowerShell to SharePoint Online

image

So you have configured your environment to have PowerShell connect to Office 365 using my previous blog post:

Configuring PowerShell access in Office 365

However, this only used to provide access to tenant and Exchange administration. With the Wave 15 release of Office 365 you can now also connect to SharePoint Online. here is how to do just that.

You are going to need a machine that has the Windows Management Framework 3.0 installed, which basically means you need PowerShell version 3.0. if you are keeping up with the times and running Windows 8 as your desktop then you already have PowerShell 3.

Next you’ll to install the SharePoint Online Management Shell. The latest one I found is here:

http://www.microsoft.com/en-us/download/details.aspx?id=35588

I also found an earlier preview following some links but I’d suggest the latest version is what you want.

So on the Windows 8 machine on which you have the Microsoft Online Services Module for Windows PowerShell installed ,run it as an administrator and accept the UAC.

image

The next step is to load in the SharePoint Online cmdlets for use in this session. after some digging around I found that they are called:

Microsoft.Online.Sharepoint.PowerShell

image

So at the prompt type:

import-module microsoft.online.sharepoint.powershell

that should result in the above warning.

image

Now you will need to log into your Wave 15 account. i normally do this by saving the login details to a variable by typing the following:

$cred=get-credentials

A dialog windows as shown above will appear into which you need to enter the login and password of a suitably enabled Office 365 user who can administer SharePoint Online. If in doubt use the initial global administrator that was provisioned with your site.

image

The next step is now to use those credential to connect to SharePoint Online. To do this execute the following line:

connect-sposervice –url https://-admin.sharepoint.com –credential $cred

in my case this was:

connect-sposervice –url https://ciaops365e1-admin.sharepoint.com –credential $cred

image

In true PowerShell form, if everything is correct you will simply be returned to a prompt. Now you can execute commands against SharePoint Online. For example the following will display all your SharePoint Online sites by URL in a table:

get-sposite | ft “url”

Now you can start exploring all the cmdlets that are available for SharePoint Online which you can find at the bottom of this page:

http://office.microsoft.com/en-au/sharepoint-help/introduction-to-the-sharepoint-online-management-shell-HA102915057.aspx

Does the same process work on Wave 14 tenants that haven’t yet been upgraded to Wave 15 and SharePoint 2013?

image

I tried it on my Wave 14 tenant (https://ciaops365.sharepoint.com) above and it worked! Excellent, roll on SharePoint Online control via PowerShell everywhere.

Leave a comment