5

While trying to execute this Power-shell command:

$site = Get-SPSite  "http://mysite/"

facing:

Get-SPSite : Cannot find an SPSite object with Id or Url: http://mysite/. At line:1 char:9 + $spSite = Get-SPSite <<<< " + CategoryInfo : InvalidData: (Microsoft.Share...SPCmdletGetSite: SPCmdletGetSite) [Get-SPSite], SPCmdletPipeBindException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite

1
  • Hi Sam, Did you ever find the reason for the error? Thanks
    – Daniel
    Commented Nov 8, 2016 at 19:42

5 Answers 5

5

Maybe this user doesn't have enough permissions to get spsite. Add him as SPShellAdmin in content database please.

$db = Get-SPContentDatabase -site http://sharepoint 
Add-SPShellAdmin -UserName SPSP_User -database $db

reference blog

1
  • Get-SPContentDatabase gives the same error. I have manually found the databaseid and assigned it and added the Add-SPShellAdmin to the database. It still gives the same error after adding the user as shelladmin. I do have all requisite permissions on the contentdb.
    – Daniel
    Commented Oct 21, 2016 at 21:12
4

I had this same issue and a coworker suggested adding the user to the SPDataAccess role in SQL for the content database. This was all it took to resolve.

1
  • Life saver. For me Get-SPSite was working but Get-SPWeb was not. The account already had spshelladmin and even removing and re-adding spshelladmin didn't help. Adding this role to the user did the trick, thanks. Commented Jan 31, 2018 at 18:10
0

You have the same error message if the Security Token Service does not function properly. See this blog post for the detailed description.

0

Run command $site = Get-SPSite -Identity "http://mysite/"

-1

Make sure that you run the SharePoint power-shell command on the same machine(Farm) containing the site, otherwise it will not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.