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.

Solution:

  • 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 installed or loaded. In the above case, Make sure you have 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!)

You may have the similar error for other modules as well, E.g. “Connect-Exopssession is not recognized as the name of a cmdlet”, “pip is not recognized as the name of a cmdlet”, “Get-ADGroupMember is not recognized as the name of a cmdlet”, etc. You got to install the relevant module to your computer prior to using these cmdlets.

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time 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

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