I know I said it several times, but I'll say it again: I'm a big Fan of PowerShell! PowerShell makes repetitive tasks easier and less tedious. It helps to automate complex tasks and reduces risk of human error. In this article, I'm exploring how to use PowerShell with SharePoint online.
Using PowerShell for SharePoint Online:
Follow these steps to use PowerShell with SharePoint online sites.
Step 1: Download and Install SharePoint online PowerShell module:
You must download and install SharePoint Online Management Shell to start with. Download PowerShell for SharePoint online at: https://www.microsoft.com/en-us/download/details.aspx?id=35588
Step 2: Connect to SharePoint online with PowerShell
Launch "SharePoint Online Management Shell" from start menu and connect to SharePoint Online Administration Center first.
Connect-SPOService -Url https://salaudeen-admin.sharepoint.com ` -credential firstname.lastname@example.orgThis cmdlet must be run before we use any other SharePoint Online cmdlets. Make sure you connect with an account with the global administrator permissions and use HTTPS in the admin site URL. You'll get The prompt for password.
Step 3: Start using SharePoint online PowerShell cmdlets!
Once connected, you can use SharePoint Online cmdlets. Here are some examples. Lets create a site collection in SharePoint online using PowerShell.
SharePoint online PowerShell create site collection
#Lets create a new Site collection: New-SPOSite -Url https://salaudeen.sharepoint.com/sites/Sales ` -Owner email@example.com -StorageQuota 1000 -Title "Sales Site"
Create group in SharePoint Online with PowerShell ISE:
You can also use PowerShell ISE. Lets create a group using PowerShell for SharePoint online.
#sharepoint online powershell create group: #Connect to SharePoint Online Connect-SPOService -Url https://salaudeen-admin.sharepoint.com ` -credential firstname.lastname@example.org #create group New-SPOSiteGroup -Site https://salaudeen.sharepoint.com/sites/Sales ` -Group "Sales Managers" -PermissionLevels "Full Control"
Index of SharePoint online PowerShell cmdlets:
For the list of available cmdlets for SharePoint online, Refer: SharePoint online 2013 PowerShell cmdlets at
You can also use this cmdlet to list SharePoint online PowerShell cmdlets:
Get-Command –Module Microsoft.Online.SharePoint.PowerShell
Limitation: Unlike SharePoint on-premises, SharePoint online offers only least set of PowerShell cmdlets to manage SharePoint online. E.g. There is no direct PowerShell cmdlets to activate feature, create subsite, create list, add list item, add user to group, etc. Solution would be utilizing client side object model (CSOM) with PowerShell! I'll write an another post on how to manage SharePoint online with PowerShell and client object model.
You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.