Sunday, November 10, 2019

Tools for Newbies: PowerShell


New to SharePoint?  Finding yourself a little overwhelmed?  This is the first in a series of posts about the most useful tools for both SharePoint developers and admins. Whether you're completely new to the game or you've been in it since the beginning, these skills are invaluable.  I'll guide you through getting set up and point you toward resources that I find extremely helpful.

Today's Tool: PowerShell

Too on the nose?
I use PowerShell weekly, sometimes daily depending on what's on my plate.  This is one of those skills that is necessary for both developers and admins to know, and definitely useful for power users to understand.  Even if you're not allowed to run PowerShell at your job--maybe you're a site owner without SharePoint Admin permissions-- it's essential to know what is possible so that you can streamline your requests with IT.

There are so many PowerShell modules available that it can seem a bit overwhelming.  For our purposes, let's focus on the basics of using PowerShell against SharePoint Online.  For this you'll need a special version of the PowerShell console called SharePoint Online Management Shell  (download here!).  Management Shell comes loaded with all the modules you'll need to work with SharePoint Online.

Once you have that installed, go ahead and start up an instance of Management Shell by choosing it from your list of programs.  You'll notice that when it opens it points to a default destination.  If we were going to run a script stored on the file system we would change it, but for now this is fine.


The nuts and bolts

Everything we do in PowerShell starts with what are called cmdlets (pronounced: "Command-lets").  Cmdlets are the building blocks of PowerShell scripts, and each one refers to specific functionality and may take various parameters.  Examples of SharePoint Online cmdlets are:
  • Get-SPOSite
  • Add-SPOSiteDesign
  • Invoke-SPOSiteSwap
When it comes to SharePoint Online, the first cmdlet we need to use is Connect-SPOService.  This is the gate we need to pass through every time we want to work with SPO, and we pass in the SharePoint admin URL as a parameter.

Inside the Management Shell console, type in the cmdlet and your URL as below and press Enter.  When prompted, login using SharePoint Online Administrator credentials.  



Once connected, the SharePoint world is your oyster!  For instance, we can use the Get-SPOSite cmdlet without any parameters to return all the site collections in the tenant.  



To return a specific site, use the -Identity parameter and provide the URL of the site.  To return more information about the site, use the -detailed parameter.



There are cmdlets available for many basic processes, and PowerShell allows you to handle batch and routine processes quickly and easily.  Now that you've gotten your feet wet, go forth and script!  For the full reference, review the Microsoft Documentation.






Header Photo by Jo Szczepanska on Unsplash

Body Photo by Aaron Burden on Unsplash


1 comment:

  1. Great information thanks for sharing such a valuable information

    ReplyDelete