Forum Discussion
Powershell script to delete all versions of files in a sharepoint site from all libraries
Hi rohankapz,
The error message you are getting means that the PowerShellGet module cannot find the Microsoft.SharePointOnline.CSOM module in any of the registered module repositories.
To fix this, you can try the following:
- Make sure that you have the latest version of PowerShell installed.
- Make sure that you have the PowerShellGet module installed. If you don't, you can install it using the following command:
Install-Module PowerShellGet
Clear the PowerShellGet module cache using the following command:
Update-Module -Name PowerShellGet -Force
Try installing the Microsoft.SharePointOnline.CSOM module again using the following command:
Install-Module -Name Microsoft.SharePointOnline.CSOM -Force -AllowClobber
If you are still getting the same error, you can try installing the Microsoft.SharePointOnline.CSOM module manually. To do this, download the module from the following website:
- Microsoft.SharePointOnline.CSOM NuGet package: https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM/
Once you have downloaded the module, extract it to a folder on your computer. Then, open a PowerShell console and navigate to the folder where you extracted the module. Finally, run the following command to install the module:
Install-Module -Path .\Microsoft.SharePointOnline.CSOM
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows PS C:\Windows\system32> winget search Microsoft.PowerShell Name Id Version Source --------------------------------------------------------------- PowerShell Microsoft.PowerShell 7.3.7.0 winget PowerShell Preview Microsoft.PowerShell.Preview 7.4.0.5 winget PS C:\Windows\system32> Install-Module PowerShellGet
PS C:\Windows\system32> Update-Module -Name PowerShellGet -Force
WARNING: The version '1.4.8.1' of module 'PackageManagement' is currently in use. Retry the operation after closing the applications.
PS C:\Windows\system32> Install-Module -Name Microsoft.SharePointOnline.CSOM -Force -AllowClobber
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'Microsoft.SharePointOnline.CSOM'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9711 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>
- LeonPavesicSep 22, 2023Silver Contributor
Hi rohankapz,
thanks for the update.To troubleshoot the issue of installing the Microsoft.SharePointOnline.CSOM module in PowerShell 7, try the following:
- Restart your computer. This can sometimes fix minor issues that can prevent modules from installing correctly.
- Make sure that you have the latest version of PowerShell 7 installed. You can check for updates by running the following command:
winget upgrade Microsoft.PowerShell
- Make sure that you have the PowerShellGet module installed. If you don't, you can install it using the following command:
winget install Microsoft.PowerShell.PackageManagement
- Clear the PowerShellGet module cache. You can do this by running the following command:
Update-Module -Name PowerShellGet -Force
- Try installing the Microsoft.SharePointOnline.CSOM module again. You can do this by running the following command:
Install-Module -Name Microsoft.SharePointOnline.CSOM -Force -AllowClobber
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
- rohankapzSep 22, 2023Copper Contributor