How to Install / Update / Uninstall SharePoint Online PowerShell Module?

SharePoint Online Management Shell is available as a module in PowerShell Gallery now! So, you can install it as a module directly from PowerShell instead of downloading and installing the MSI file! This makes it easier to update. Here is how to install SharePoint Online PowerShell module:

Prerequisites: The Install-module cmdlet comes with the "PowerShellGet" module which comes with Windows 10, Windows 2016, or later. In older operating systems, You can get it through Windows Management Framework (WMF) 5.1 or later.

How to find your SharePoint Online PowerShell version?
To getting started, check if you have already installed the SharePoint Online Management Shell in your system by running the following command in the administrative mode in PowerShell:
Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version
This finds your SharePoint online PowerShell version installed.

How to Install SharePoint Online PowerShell Module?
The SharePoint Online Management Shell is a Windows PowerShell module that can be installed in your Windows client machine or Server. To install the PowerShell Module for SharePoint Online, Open PowerShell as Administrator and enter:
Install-Module Microsoft.Online.SharePoint.PowerShell
install sharepoint online powershell module
Confirm the prompt and you'll see PowerShell module for SharePoint Online starts downloading and installing:
sharepoint online powershell module install
To re-install SharePoint Online PowerShell module, use: -Force switch:
Install-Module Microsoft.Online.SharePoint.PowerShell -force
Please note,  installing PowerShell module for SharePoint Online doesn't install "SharePoint Online Management Shell" in your PC, but you can run any SharePoint Online cmd-lets directly in Windows PowerShell itself! Once installed, You can get a list of cmdlets from the module using:
Get-command -Module Microsoft.Online.SharePoint.PowerShell
Get-command -Module Microsoft.Online.SharePoint.PowerShell

Let's check If SharePoint Online PowerShell Module is installed. If not, install it.
#Check if SharePoint Online PowerShell module has been installed
Try {
    Write-host "Checking if SharePoint Online PowerShell Module is Installed..." -f Yellow -NoNewline
    $SharePointOnlineModule = Get-Module -ListAvailable "Microsoft.Online.SharePoint.PowerShell"

        Write-host "No!" -f Green

        #Check if script is executed under elevated permissions - Run as Administrator
        If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
            Write-Host "Please Run this script in elevated mode (Run as Administrator)! " -NoNewline
            Read-Host "Press any key to continue"

        Write-host "Installing SharePoint Online PowerShell Module..." -f Yellow -NoNewline
        Install-Module "Microsoft.Online.SharePoint.PowerShell" -Force -Confirm:$False
        Write-host "Done!" -f Green
        Write-host "Yes!" -f Green
        Write-host "Importing SharePoint Online PowerShell Module..." -f Yellow  -NoNewline
        Import-Module "Microsoft.Online.SharePoint.PowerShell" -DisableNameChecking
        Write-host "Done!" -f Green
    write-host "Error: $($_.Exception.Message)" -foregroundcolor red

Update SharePoint Online PowerShell module
How to update SharePoint Online management shell? To update the SharePoint Online PowerShell Module, use:

Uninstall SharePoint Online PowerShell Module
To remove the SharePoint Online PowerShell module, use:
Uninstall-Module -Name Microsoft.Online.SharePoint.PowerShell

To install SharePoint Online PnP PowerShell module, refer: Install SharePoint Online PnP PowerShell Module

1 comment:

  1. WOW This is the best, most educational and useful site on SharePoint I've ever seen.



Please Login and comment to get your questions answered!

Powered by Blogger.