Install/Update/Uninstall Cmdlets for SharePoint Online

Installing SharePoint cmdlets it’ll most likely be a requirement when you’re developing on SharePoint either Online or On-prem. In this article, we’ll explain how to install, update, check the current version and uninstall these PowerShell solutions.

To start, I’ll always recommend you install these cmdlets by PowerShell since will be easier when there is an update because you don’t need to download the .msi.

Execution Policy

Get-ExecutionPolicy #Check the current ExecutionPolicy 
Set-ExecutionPolicy -ExecutionPolicy  Unrestricted

SharePoint Online Management Shell

Install:

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

Check the current version:

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

Update:

Update-Module -Name Microsoft.Online.SharePoint.PowerShell

Uninstall:

Uninstall-Module -Name Microsoft.Online.SharePoint.PowerShell

PnP PowerShell

Install:

Install-Module -Name "PnP.PowerShell"
#Force will force to install the latest version

Check the version:

Get-Module "PnP.PowerShell" -ListAvailable | Select-Object Name,Version | Sort-Object Version -Descending

Update:

Update-Module "PnP.PowerShell"

Uninstall

Uninstall-Module -Name "PnP.PowerShell"

References

https://pnp.github.io/powershell/index.html

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6

https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-online/connect-sharepoint-online?view=sharepoint-ps

https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-pnp/sharepoint-pnp-cmdlets?view=sharepoint-ps

8 Comments

  1. Thamizhannai Kurinjiselvan said:

    I’m getting the below error when I install module.
    Update-Module : Module ‘SharePointPnPPowerShellOnline’ was not updated because no valid module was found in the module directory. Verify that the module is located in
    the folder specified by $env:PSModulePath.
    At line:1 char:1
    + Update-Module SharePointPnPPowerShellOnline
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (SharePointPnPPowerShellOnline:String) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : ModuleNotInstalledOnThisMachine,Update-Module

    April 16, 2020
    Reply
  2. Kevin Bilello said:

    I am facing a similar error that will allow me to use powershell scripts to upload files to a SharePoint document library. I am wondering if this may have a similar resolution. Please see below. Thank you in advance.
    PS C:\Windows\system32> Install-Module -Name Microsoft.Online.SharePoint.PowerShell
    WARNING: Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’.
    WARNING: Unable to resolve package source ‘https://www.powershellgallery.com/api/v2/’.
    PackageManagement\Install-Package : No match was found for the specified search criteria and module name ‘Microsoft.Online.SharePoint.PowerShell’. Try Get-PSRepository to see all available
    registered module repositories.
    At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2\PSModule.psm1:9683 char:34
    + … talledPackages = PackageManagement\Install-Package @PSBoundParameters
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Microsoft.Power….InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

    PS C:\Windows\system32> Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version
    PS C:\Windows\system32> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    PS C:\Windows\system32> Install-Module PowerShellGet -RequiredVersion 2.2.4 -SkipPublisherCheck
    WARNING: Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’.
    WARNING: Unable to resolve package source ‘https://www.powershellgallery.com/api/v2/’.
    PackageManagement\Install-Package : No match was found for the specified search criteria and module name ‘PowerShellGet’. Try Get-PSRepository to see all available registered module repositories.
    At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2\PSModule.psm1:9683 char:34
    + … talledPackages = PackageManagement\Install-Package @PSBoundParameters
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Microsoft.Power….InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

    June 2, 2020
    Reply
    • David Ramalho said:

      Hi Kevin,

      I did some search but didn’t find a clear answer. I would try this to begin:

      [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
      Set-ExecutionPolicy RemoteSigned

      You can find more alternatives here – https://github.com/PowerShell/PowerShell/issues/7827.
      Let me know which one worked

      My best,
      David Ramalho

      June 2, 2020
      Reply
  3. Harry said:

    Perfect. Been looking for it.

    June 9, 2020
    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *