PowerShell Modules for Managing SharePoint Online
As a SharePoint Online administrator you have several tools available to you for automating tenant administration. When you are setting up a new workstation it can be challenging to figure out what to install and where to get it. This post summarizes the various PowerShell tools available for managing your SharePoint Online tenant.
Microsoft Online Services Sign-in Assistant
The Microsoft Online Services Sign-In Assistant provides end user sign-in capabilities to Microsoft Online Services, such as Office 365. This is required for using most of the other modules in this post and is likely installed if you are using Office applications on your workstation.
Microsoft Online Services Sign-In Assistant for IT Professionals RTW https://www.microsoft.com/en-us/download/details.aspx?id=41950
SharePoint Online Management Shell
This is used for performing core SharePoint Online service administration.
Option #1 Download and install the SharePoint Online Management Shell
- Download sharepointonlinemanagementshell_6112-1200_x64_en-us.msi
- Run the installer
- Once installed you can load this module into your scripts using:
[powershell]Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking[/powershell]
SharePoint Online Management Shell https://www.microsoft.com/en-us/download/details.aspx?id=35588
Option #2 Install the SharePoint Online Management Shell from the PowerShell Gallery
If your operating system is using PowerShell 5.0 or newer, you can install the
SharePoint Online Management Shell by using the following command:
[powershell]Install-Module -Name Microsoft.Online.SharePoint.PowerShell[/powershell]
Announcing availability of SharePoint Online Management Shell from PowerShell Gallery https://techcommunity.microsoft.com/t5/Microsoft-SharePoint-Blog/Announcing-availability-of-SharePoint-Online-Management-Shell/ba-p/241370
Office Dev PnP PowerShell Module
This solution contains a library of PowerShell commands that allows you to perform complex provisioning and artifact management actions towards SharePoint. The commands use CSOM and many can work against both SharePoint Online and SharePoint Server.
Install Module:
[powershell]Install-Module SharePointPnPPowerShellOnline -AllowClobber[/powershell]
Module Information https://github.com/SharePoint/PnP-PowerShell
SharePoint Online Client Side Object Model (CSOM)
For scenarios that are not covered by the SharePoint Online Management Shell or the Office Dev PnP PowerShell module you will need access to the client side object module.
Installing Package without Visual Studio installed
- Download the NuGet Commandline:
- From the directory where you saved nuget.exe:
[plain]Nuget install Microsoft.SharePointOnline.CSOM -OutputDirectory C:\<TargetDIR>\SPO_CSOM[/plain]
Package Information https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM
Azure Azure AD Management Shell
This is used for managing top tenant level settings and for managing user provisioning and licensing. This requires global administrator rights and will not be necessary for many SharePoint operations.
Azure ActiveDirectory V1
Please note that cmdlets in this module will be deprecated when the functionality of this module is migrated to the newer Azure Active Directory PowerShell V2 Module. We advise customers who are creating new PowerShell scripts to use the newer module instead of this module.
https://github.com/Azure/azure-docs-powershell-azuread/blob/master/Azure%20AD%20Cmdlets/MSOnline/index.md
Install AzureAD Management Shell V1
- Download AdministrationConfig-V1.1.166.0-GA.msi
- Run the installer file
- Import the module in your script by running:
[powershell]Import-Module MSOnline[/powershell]
Azure Azure AD Management Shell (V2)
This is the newer module for managing AzureAD but does not yet contain equivalents for all V1 cmdlets. This GA release also does not include V2 cmdlets that are in preview.
https://www.powershellgallery.com/packages/AzureAD/
Installing Azure AD Management Shell V2
[powershell]Install-Module -Name AzureAD[/powershell]
Security and Compliance Center
In your role as a SharePoint Online Administrator you may also be asked to manage some or all of the Security and Compliance center in Office 365. Managing this requires the use of Remote Powershell.
Connecting to Security and Compliance Center:
[powershell]#Enter credentials and establish connection
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/" -Credential $UserCredential -Authentication Basic -AllowRedirection
#Import cmdlets
Import-PSSession $Session
#Once you are done with your session be sure you disconnect
Remove-PSSession $Session
[/powershell]
Connect to the Office 365 Security & Compliance Center using remote PowerShell https://technet.microsoft.com/en-us/library/mt587092(v=exchg.160).aspx