Fix “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.” Error in PowerShell

Problem: When trying to run a PowerShell script in SharePoint, I got this error

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.

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.

Troubleshooting Checklist:

  • You may face this error if you try to run a PowerShell script through Windows PowerShell or PowerShell ISE and this error could be because the PowerShell module for SharePoint is not loaded. Make sure you add “Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue” in Line#1. Alternatively, you can use “SharePoint 2016 Management Shell” which loads the necessary modules by default.
  • You must run the PowerShell script for SharePoint On-premises in any of the SharePoint Server in the server farm (and not from your client machine!)

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

2 thoughts on “Fix “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.” Error in PowerShell

  • How can I do the same on SharePoint Online? According to MS documentation, Get-SPWeb is only applicable in SharePoint Server Subscription Edition. It seems the equivalent cmdlet in SharePoint online is “Connect-SPOService” followed by “Get-SPOSite”, but “Connect-SPOService” requires the admin site (e.g. “https://xxx-admin.sharepoint.com/”), so “https://xxx.sharepoint.com/sites/kyle22/” doesn’t work.

    Reply

Leave a Reply