Installing and configuring PowerShell cmdlets for SharePoint Online and Office 365

I will admit it; I put this off for as long as I could. Why? Because I just wasn’t really sure what went into getting connected to my O365 subscription and I knew that there wasn’t a lot of cmdlets there. Good news I have solved both of these problems for you. The following will get you up and running with O365, Exchange Online, Skype for Business Online (Lync Online) and SharePoint Online.

If you like words, then keep reading. If you would rather me show you then you can watch my step-by-step video: Installing and Configuring PowerShell for Office 365 and SharePoint Online. The choice is yours.

Also, Microsoft does have a website that covers getting started with PowerShell. You can find most of this stuff written there, just not with my fun comments along the way.

Making sure you are ready

  1. You need to have local administrator access to install the following items.
  2. Your PowerShell execution policy needs to allow remote scripts
    1. Open PowerShell by right-clicking and running as administrator.
    2. Get-ExecutionPolicy will tell you what you currently have. Restricted will not work.
    3. Get-ExecutionPolicy
    4. If you are Restricted, then you will have to lower your policy. I recommend the following.
    5. Set-ExecutionPolicy RemoteSigned
  3. You need to be an O365 administrator to run all of the cmdlets.

The things  you need to install

There are four pieces that you need to install. And the good news is they are all next, next, finish. 🙂 Only decision you need to make is do you want the 32bit or 64bit versions. The good news is the 32bit stuff is deprecated so I am 99% sure you want the 64bit.

  1. Sign-on Assistant
  2. The Subscription management pieces
  3. SharePoint Online pieces
  4. Skype for Business Online pieces

That is all of the installing you need to do.

Getting connected

It would be rather rude if I didn’t help you also get logged in since that is probably a little more confusing than the next, next, finish of above. Remember you don’t have to connect to everything, every time. If you just need to create a Site Collection, then you can just do steps 1, 2, & 5. Also, a reminder I do a MUCH BETTER job explaining this stuff in the video.

  1. Open PowerShell as an administrator
  2. Set a variable with your credentials. That way you don’t have to keep typing in that long and secure(?) username and password.
    $credential = get-credential
  3. Connect to the Management of O365
    1. Import-Module MSOnline
    2. Connect-MsolService -Credential $credential
  4. Connect to Skype for Business Online (aka Lync Online). For these cmdlets, you are using PowerShell Remoting and running the cmdlets against the server in the cloud. So make sure when you are done you kill your session. If not you can lock out yourself or others until the sessions expire.
    1. Import-Module LyncOnlineConnector
    2. $lyncSession = New-CsOnlineSession -Credential $credential
    3. Import-PSSession $lyncSession

      Use the following to remove your session when you are done working with Skype.

    4. Remove-PSSession $lyncSession
  5. Connect to SharePoint Online (If you find these cmdlets lacking, and you will, then check out the Patterns and Practices cmdlets for some real power.)
    1. Import-Module Microsoft.Online.Sharepoint.PowerShell
    2. Connect-SPOService -url -Credential $credential
  6. Connect to Exchange Online. Like Skype, this is also a remote session you will need to close when you are done.
    1. $ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "" -Credential $credential -Authentication "Basic" -AllowRedirection
    2. Import-PSSession $ExchangeSession

      Use the following to remove your session when you are done working with Skype

    3. Remove-PSSession $ExchangeSession

That will do it. You can now PowerShell against O365 until the cows come home. I have some videos/posts in the hopper that will take a deeper dive into using this stuff. This post was just to make sure you could get started.


SharePoint, Azure, O365, & PowerShell Consulting

Leave a Reply