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. http://powershell.office.com/ You can find most of this stuff written there, just not with my fun comments along the way.
Making sure you are ready
- You need to have local administrator access to install the following items.
- Your PowerShell execution policy needs to allow remote scripts
- Open PowerShell by right-clicking and running as administrator.
- Get-ExecutionPolicy will tell you what you currently have. Restricted will not work.
-
Get-ExecutionPolicy
- If you are Restricted, then you will have to lower your policy. I recommend the following.
-
Set-ExecutionPolicy RemoteSigned
- 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.
- Sign-on Assistant
- The Subscription management pieces
- SharePoint Online pieces
- 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.
- Open PowerShell as an administrator
- 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
- Connect to the Management of O365
-
Import-Module MSOnline
-
Connect-MsolService -Credential $credential
-
- 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.
-
Import-Module LyncOnlineConnector
-
$lyncSession = New-CsOnlineSession -Credential $credential
-
Import-PSSession $lyncSession
Use the following to remove your session when you are done working with Skype.
-
Remove-PSSession $lyncSession
-
- 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.)
-
Import-Module Microsoft.Online.Sharepoint.PowerShell
-
Connect-SPOService -url https://contoso-admin.sharepoint.com -Credential $credential
-
- Connect to Exchange Online. Like Skype, this is also a remote session you will need to close when you are done.
-
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection
-
Import-PSSession $ExchangeSession
Use the following to remove your session when you are done working with Skype
-
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.
Shane