As a growing topic in the SharePoint world, I thought I’d write a short series about the SharePoint Online Management Shell and highlight some of the more powerful ways you can get it working for you.
- Introduction (this post)
- Setup the PowerShell session
- Connecting and disconnecting to SPOnline
- Example: Enumerating Sites
- Example: Creating a SharePoint ClientContext
- Example: Re-Indexing a site
- Securing the password
- Putting it all together
I’ve come across many traditional SharePoint Admins who are reluctant to delve into the world of managing their SharePoint Online tenant through PowerShell. Most commonly, it’s simply down to a lack of confidence or understanding just how to get going. Of course, getting setup is easy enough, and Microsoft give us the process (see References) and it really couldn’t be easier. However, what can you do once you’ve connected to your SPO tenant? The PowerShell Command Builder (see References) gives us access to 33 cmdlets, varying from simple daily tasks (like adding and removing users, creating / deleting / restoring sites, etc) and some more one-off activities (such as upgrading sites, configuring the tenant, etc). Honestly though, it’s easy to get frustrated at how basic the functionality currently offered is, and while I’m confident Microsoft are busy working on improving them, for now anything above and beyond the basics will need to be done with a little more effort. There are (as always) a number of ways, but my favourite (and the one I’ll cover in this series) is combining the OOTB cmdlets with the ClientContext class (see References) to leverage the context of SharePoint objects and operations.
What I hope to achieve in this series is to provide the essentials of using the SharePoint Online Management Shell and help to build a “primer” script that you can re-use for all SPOnline activities via PowerShell.
- Set up the SharePoint Online Management Shell Windows PowerShell environment – https://technet.microsoft.com/en-us/library/fp161372.aspx
- PowerShell Command Builder – https://www.microsoft.com/resources/TechNet/en-us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.html
- MSDN ClientContext Class – https://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.client.clientcontext.aspx