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.
- 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!)