Configuring SharePoint & Microsoft Teams PowerShell environment

Windows PowerShell ISE

Here is a list of steps that I usually complete when configuring a PC, so that I can run PowerShell script that connects to SharePoint Online and Microsoft Teams.

SharePoint Online Client Components SDK

The SharePoint Online Client Components SDK can be used to enable development with SharePoint Online. …[Microsoft] recommend using NuGet packages rather than installing CSOM assemblies to GAC. However, I find these DLLs useful when writing CSOM directly within my PowerShell scripts. 

Click here to select and download the relevant MSI file.

Open Windows PowerShell ISE as Administrator

To be able to complete the other steps that follow, we need to run the Windows PowerShell ISE as Administrator. If you would like to make this a more “permanent” action, follow these steps:

  • Search for Windows PowerShell ISE and Pin to the Start menu
  • Right click on the pinned tile and click on More and Open file location
  • Locate the Windows PowerShell ISE shortcut, right-click and select Properties 
  • Click Advanced… and select Run as administrator
  • Finish by clicking OK, Apply and OK 

From now on, when opening the Windows PowerShell ISE application from the Start menu, you will be prompted by: “Do you want this App to change your device.” Don’t forget to click Yes.

Note: If you do not open Windows PowerShell ISE with “Run as Administrator” you will not be able to set the Execution Policies. 

Check Your PowerShell Version 

The Microsoft Teams PowerShell Module has some known issues with PowerShell 7.
For the best experience, [Microsoft] recommend that you use PowerShell 5.1. If we are running anything newer than 5.x then you may need to down-grade… 

Run the following PowerShell code to check the PowerShell version

Get-Host | Select-Object Version; 

Execution Policies 

Generally, the execution policies on new machines are set to a level that will restrict the installation and running of our scripts. See the About Execution Policies article for information on how to manage them. Running the following PowerShell cmdlet to see what your current Execution Policy is set to:

Get-ExecutionPolicy;

I usually set my Execution Policy to Unrestricted, by running the following PowerShell cmdlet:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted; 

Install SharePoint Online Management Shell 

The SharePoint Online Management Shell is a tool that contains a Windows PowerShell Module to manage your SharePoint Online subscription in Office 365. 

I would recommend using the PowerShell cmdlet instead of the .MSI files, as the process for updating modules later are simpler. Click here for more information about the SharePoint Online Management Shell.

Run the following cmdlet, in administrative mode, to see if the SharePoint Online Management Shell has already been installed:

Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version;

Or run the following cmdlet, in administrative mode, to install the latest version of the SharePoint Online Management Shell:

Install-Module -Name Microsoft.Online.SharePoint.PowerShell;

Install PnP PowerShell Library

SharePoint Patterns and Practices (PnP) contains a library of PowerShell commands (PnP PowerShell) that allows you to perform complex provisioning and artifact management actions towards SharePoint. The commands use CSOM and can work against both SharePoint Online and SharePoint On-Premises (depending on the modules installed)

Click here for more information or run the following cmdlet to install the SharePoint Online PnP PowerShell library:

Install-Module SharePointPnPPowerShellOnline;

Install Microsoft Teams PowerShell

Microsoft Teams PowerShell is a set of cmdlets for managing Teams directly from the PowerShell command line.

Warning: There are known issues with PowerShell 7 and Teams PowerShell. For the best experience, we recommend that you use PowerShell 5.1.

Click here for more information or run the following cmdlet to install the Microsoft Teams library:

Install-Module MicrosoftTeams;

Upgrading PowerShell Libraries

As a rule, I avoid using the Update-Module cmdlet as this results in having multiple versions of the same library installed. Instead, I like to use the Uninstall-Module cmdlet before then installing the latest version.