[Solved] Fix the "The term 'Get-SPWeb' is not recognized as the name of a cmdlet, function" PowerShell error

[Solved] Fix the “The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function” PowerShell error

No comments

 2,868 total views,  150 views today

In this troubleshooting, I will share how to fix the “The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function” PowerShell error. Many times, we may notice even though we pass the correct URL to the Get-SPWeb command as an Identity parameter, still, we could see the error – “The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function….”

For example, once we try to run the below Get-SPWeb command,

$web = Get-SPWeb “http://server:port”

We will get the below error:

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 root cause of this error and Fix:

The PowerShell module isn’t being imported into the Powershell console. You can add the module by running:

[Solved] Fix the "The term 'Get-SPWeb' is not recognized as the name of a cmdlet, function" PowerShell error
Fix the “The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function” PowerShell error

Add-PSSnapin Microsoft.Sharepoint.Powershell

Once we add the “Add-PSSnapin Microsoft.Sharepoint.Powershell” command, then if we run the same Get-SPWeb command, we will not get that error.

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

You will not see the above error when,

  • If you open the SharePoint 2016 Management Shell.

Note: It could be any versions of SharePoint from your environment.

PowerShell Management Console In SharePoint 2016
PowerShell Management Console In SharePoint 2016

 

 

However, we will face the “The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function” error when we open the below PowerShell console or editor:

  • Windows PowerShell
  • Windows PowerShell ISE

Summary:

Thus, in this SharePoint PowerShell troubleshooting, we have learned about how to fix the “The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function” error.

You may also like the following SharePoint PowerShell tutorials: