Friday, December 19, 2014

SharePoint 2013: Cannot find an SPWeb object with Id or URL

Problem

You've logged into a farm server with the SharePoint Setup User Administrator account.  You've opened a SharePoint management shell with elevated privileges.  You are attempting to import a document library using the SPWeb object but experience this error:
Import-SPWeb : Cannot find an SPWeb object with Id or URL : <URL>...
This can occur when the account you are logged in as has not been added to the SharePoint_Shell_Access role of the content and/or farm configuration databases.  Generally, you want your administrator account to be added to this role for all farm content databases and the farm configuration databases so that you can manage them from a PowerShell.

In the following procedure, you will first get the GUIDs associated with the content databases.  Then, you will check each content database and the farm configuration database for the accounts that have had the SharePoint_Shell_Access role added to them.  Lastly, you will add the role to the desired account for each database.

Solution
  1. Note down the following information:
    1. The account you used trying to perform the import that resulted in the error (call it User.Account)
    2. The name of the content database containing the site into which you wanted to perform the import (call Content_A).
  2. Login to a SharePoint farm server using the SharePoint Setup User Administrator account.
  3. Launch an elevated instance of the SharePoint 2013 Management Shell.
  4. Execute Get-SPContentDatabase.  This returns a list of all farm content databases, along with summary information and including the database GUID.
  5. Note down the content databases and their GUIDs.
  6. Execute Get-SPShellAdmin <GUID> for each GUID noted in step 5).  This will return a list of all user accounts added to the SharePoint_Shell_Access role for that database.
  7. Note down where the account in step 1) above is missing from the role.
  8. Execute: Get-SPShellAdmin.  This will return a list of all user accounts added to the SharePoint_Shell_Access role for the farm configuration database.
  9. Execute: Add-SPShellAdmin -UserName DOMAIN\User.Account <GUID> for each content database identified in step 5). Executing this command adds this role for both the content database and for the farm configuration database. 
    If you experience an error trying to add this role to that account, perform the steps in this reference.
  10. Repeat step 6) - 8) to verify that the SharePoint_Shell_Access role has now been added to the desired account.
References
Notes
  • If you experience an error trying to add this account to that role, perform the steps in this reference.

No comments: