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

  • Hi Sam, Did you ever find the reason for the error? Thanks – Nate Nov 8 '16 at 19:42
3

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

  • 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. – Nate Oct 21 '16 at 21:12
2

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.

  • 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. – madamission Jan 31 '18 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.

-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, privacy policy and cookie policy

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