[Fixed] The term ‘get-spweb’ is not recognized as the name of a cmdlet function PowerShell SharePoint error

This SharePoint tutorial explains how to fix the term ‘get-spweb’ is not recognized as the name of a cmdlet function PowerShell SharePoint error that comes while running the get-spweb cmdlet.

How to fix the error the term ‘get-spweb’ is not recognized as the name of a cmdlet function? To fix the issue just add Add-PSSnapin Microsoft.Sharepoint.Powershell PowerShell snap-in.

the term ‘get-spweb’ is not recognized as the name of a cmdlet function

Recently, while working with SharePoint using PowerShell, I was running the below command:

$SPWeb = Get-SPWeb "http://win-pfcp2dgt8di/sites/EnjoySharePoint/"

The error can also come in SharePoint 2013, SharePoint 2016 or SharePoint 2019 version.

I got an error that says:

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:10

  • $SPWeb = Get-SPWeb “http://win-pfcp2dgt8di/sites/EnjoySharePoint/”
  • ~~~~~
    • CategoryInfo : ObjectNotFound: (Get-SPWeb:String) [], CommandNo
      tFoundException
    • FullyQualifiedErrorId : CommandNotFoundException
the term 'get-spweb' is not recognized as the name of a cmdlet function
the term ‘get-spweb’ is not recognized as the name of a cmdlet function

The error was coming because the PowerShell module isn’t being imported into the Powershell console.

Below is the code we can write to add the PowerShell SharePoint snap-in.

Add-PSSnapin Microsoft.Sharepoint.Powershell

After you add the “Add-PSSnapin Microsoft.Sharepoint.Powershell”, the Get-SPWeb command will work fine.

The full commands look like below:

Add-PSSnapin Microsoft.Sharepoint.Powershell
$SPWeb = Get-SPWeb "http://win-pfcp2dgt8di/sites/EnjoySharePoint/"

After this the error PowerShell the term ‘get-spweb’ is not recognized as the name of a cmdlet will not come. It will fix the below issues:

  • the term get-spweb is not recognized
  • the term ‘get-spweb’ is not recognized as the name of a cmdlet function
  • the term ‘get-spweb’ is not recognized as the name of a cmdlet function script
  • the term get-spweb is not recognised
  • the term ‘get-spweb’ is not recognized as the name of a cmdlet fu
See also  How To Format An Array Of Objects As Table In PowerShell?

You may also like:

>