This SharePoint PowerShell tutorial explains, how to solve The term Get-SPweb is not recognized as the name of a cmdlet function script file or operable program error which comes in PowerShell SharePoint 2013/2016/Online.
Recently when I am trying to run the below PowerShell Cmdlet:
$web = Get-SPWeb “http://win-pfcp2dgt8di/sites/EnjoySharePoint/”
I got the error saying:
Get-SPWeb : The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:8
+ $web = Get-SPWeb “http://win-pfcp2dgt8di/sites/EnjoySharePoint/”
+ ~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-SPWeb:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
The error looks like below fig:
The term Get-SPweb is not recognized as the name of a cmdlet function script file or operable program error
The error usually comes if you directly run the command in the Windows PowerShell Console.
To resolve to execute the below command first:
Add-PSSnapin Microsoft.Sharepoint.Powershell
Ideally, we should run in SharePoint 2013 Management Shell rather than only in the PowerShell console. So Open SharePoint 2013 Management Shell in Administrator mode and then run the Cmdlet the error will not come.
If you are using the Windows PowerShell ISE to run, debug or test PowerShell cmdlets, then you can write the script like below:
Add-PSSnapin Microsoft.Sharepoint.Powershell
$web = Get-SPWeb “http://win-pfcp2dgt8di/sites/EnjoySharePoint/”
If you are new to PowerShell SharePoint, then I have written a detailed article on how to working with PowerShell in SharePoint Online/2016/2013.
SharePoint Online management shell Error: The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet
If you are getting the error in SharePoint Online and you are writing the PowerShell script like below:
$web = Get-SPWeb “https://onlysharepoint2013.sharepoint.com/sites/bhawana”
When you execute the above line, you will get The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function script file or operable program error.
Because Get-SPWeb cmdlet is not for SharePoint Online. It is only for SharePoint on-premise versions.
To work with PowerShell in SharePoint Online, then you should follow PowerShell SharePoint Online cmdlets or PnP PowerShell cmdlets.
You may like following SharePoint PowerShell tutorials:
- Getting Started with PnP PowerShell – SharePoint 2013/2016/SharePoint Online
- Bulk SharePoint Online Site Collection Creation using PowerShell
- Debugging PowerShell Script with Visual Studio Code
- PowerShell Script to deploy WSP Solution in SharePoint 2013
- SharePoint 2016 PowerShell Script to list all Users in Site Collection
- Steps to Increase SharePoint Online Storage Quota using PowerShell
- Create a web application in SharePoint 2016 from Central Administration and using PowerShell
- PowerShell SharePoint Examples
After this, The term Get-SPweb is not recognized as the name of a cmdlet function script file or operable program error will not come.
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.
Getting this error:Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5.
Kindly help