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"
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
Hi,
Check the next article and let me know if this solved your issue. This is related to a recent change on PowerShell Gallery.
https://devblogs.microsoft.com/powershell/powershell-gallery-tls-support/
My best,
David Ramalho
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
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
Perfect. Been looking for it.
[…] https://sharepoint-tricks.com/install-update-uninstall-cmdlets-for-sharepoint-online/ […]
[…] First, you need to make sure you have the SharePoint Online Management Shell on the latest versions, check the following article to know how to do it – Install/Update/Uninstall Cmdlets for SharePoint Online – SharePoint Tricks (sharepoint-tricks.… […]
[…] recommend you update your PNP PowerShell to make sure you got the same cmdlets used by the script. We […]