Share via


SharePoint 2010 Troubleshooting: Get-SPWeb Access is denied

Problem

Tried executing this script (in elevated SMS) so as to get a listing of all activated features in all webs in a site collection:

Get-SPSite
 https://site/ | Get-SPWeb -Limit ALL | %{ Get-SPFeature -Web $_ } | Sort DisplayName -Unique | FT DisplayName,Id, Hidden, Status

The response was:

Get-SPWeb : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At line:1 char:46
+ Get-SPSite https://site/ | Get-SPWeb <<<< -Limit ALL | %{ Get-SPFeature -Web $_ } | Sort DisplayName -Unique | 
 FT DisplayName,Id
 + CategoryInfo : InvalidData: (Microsoft.Share....SPCmdletGetWeb:SPCmdletGetWeb) [Get-SPWeb], 
 UnauthorizedAccessException
 + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetWeb

This data was needed as part of pre-upgrade preparation from 2010 through 2016.  The site owner had previously added my user account to the site collection administrator group.

Troubleshooting

Step Action
1. Check SharePoint Shell Access to farm  granted to farm (i.e., farm configuration database).
2. Execute commandlets individually when run individually, commandlets completed without issue.
3. Check roles to site's content database  server role found to be sysadmin, and database role found to be dbo.
4. Check SharePoint Shell Access to content database  not provisioned.
5. Add SharePoint Shell Access role for database, and then re-execute script  still experienced same error.
6. Research postings on similar issue  found one indicating need to be site collection administrator to site.  
7. Add administrator account as secondary site collection administrator, and then re-execute script  script ran without error.
8. Research  found that site owner added user account and not administrator account to site collection administrators group.

Solution

Ensure that the login account executing the nested commandlets is a member of the site's site collection administrator group.

References

Notes

This is an example of a UE (user error) and not a technical problem.  It's still useful to document UE problems in order to facilitate more efficient troubleshooting.