Powershell Error "The term 'Get-SPWeb' is not recognized as the name of a cmdlet, function..."

134,435

Solution 1

I think this need to be run from the Management Shell rather than the console, it sounds like the module isn't being imported into the Powershell console. You can add the module by running:

Add-PSSnapin Microsoft.Sharepoint.Powershell

in the Powershell console.

Solution 2

Run this script from SharePoint 2010 Management Shell as Administrator.

Share:
134,435
LifeScript
Author by

LifeScript

Updated on November 22, 2020

Comments

  • LifeScript
    LifeScript over 3 years

    I just typed the follow to try and get my SharePoint site:

    $spWeb = Get-SPWeb -Identity "http://nycs00058260/sites/usitp"
    

    It gave me the following error

    The term 'Get-SPWeb' is not recognized as the name of a cmdlet, function, script...

    The url is correct so why am I getting this error?

  • LifeScript
    LifeScript over 11 years
    hi, I have a small question, how to check if the file already exists in sharepoint lib?
  • Lennon
    Lennon about 9 years
    Great! This allow us to use Windows PowerShell ISE for SharePoint related stuff, which is much better as it support multi-line functions and has syntax validation!
  • Eliezer
    Eliezer about 6 years
    if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorActionSilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" }
  • Harsha Vardhini
    Harsha Vardhini over 5 years
    Hi, I am getting error while running the mentioned command. Please check this error:Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 4. At line:1 char:1 + Add-PSSnapin Microsoft.Sharepoint.Powershell + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (Microsoft.Sharepoint.Powershell:String) [Add-PSSnapin], PSArgumentException + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCom‌​mand
  • Zack
    Zack about 5 years
    @HarshaVardhini I am getting the same error but for PowerShell version 5. Did you figure out the problem?