none
Get-SPWeb : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) RRS feed

  • Question

  • I am farm admin (can do anything inside central admin)

    I have run the powershell sharepoint management shell with "run as administrator"

    Here is what I wrote

    $siteList = Get-SPSite -Limit ALL
      
    foreach($site in $siteList) {
      try {
        $webList = Get-SPWeb -site $site.URL -Limit ALL
      }
      catch {
        write-host ("Error in site URL " + $site.URL)
        $_ | select -expandproperty invocationinfo | Format-List Line, PositionMessage -force
        write-host $_.Exception -foregroundcolor "red"    
      }
    }
    

     

    Here is the error

    Get-SPWeb : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
    At C:\Users\srabhi_adm\Documents\test.ps1:5 char:29
    +         $webList = Get-SPWeb <<<<  -site $site.URL -Limit ALL
        + CategoryInfo          : InvalidData: (Microsoft.Share....SPCmdletGetWeb:SPCmdletGetWeb) [Get-SPWeb], UnauthorizedAccessExceptio
       n
        + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetWeb

    Get-SPWeb : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
    At C:\Users\srabhi_adm\Documents\test.ps1:5 char:29
    +         $webList = Get-SPWeb <<<<  -site $site.URL -Limit ALL
        + CategoryInfo          : InvalidData: (Microsoft.Share....SPCmdletGetWeb:SPCmdletGetWeb) [Get-SPWeb], UnauthorizedAccessExceptio
       n
        + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetWeb

     

    Funny thing is that my catch block was not executed. Why did I get the error?

    Tuesday, April 12, 2011 1:48 PM

Answers

  • If you think you have enough permissions in SQL server, check that your login has full control to the Web App that you are running your command against. If not just create a user policy to give the account full control in the web applications management section in CA.

    • Marked as answer by MSDN Student Tuesday, July 19, 2011 9:11 AM
    Tuesday, July 19, 2011 2:06 AM
  • This generally means your account doesn't have access to certain resources in SQL database.  Run PS as Farm Service account.
    • Marked as answer by MSDN Student Wednesday, April 13, 2011 11:54 AM
    Tuesday, April 12, 2011 3:31 PM

All replies

  • This generally means your account doesn't have access to certain resources in SQL database.  Run PS as Farm Service account.
    • Marked as answer by MSDN Student Wednesday, April 13, 2011 11:54 AM
    Tuesday, April 12, 2011 3:31 PM
  • If you think you have enough permissions in SQL server, check that your login has full control to the Web App that you are running your command against. If not just create a user policy to give the account full control in the web applications management section in CA.

    • Marked as answer by MSDN Student Tuesday, July 19, 2011 9:11 AM
    Tuesday, July 19, 2011 2:06 AM
  • Yes. I went and gave myself FULL Control of All the Web Apps. Post that the script ran without any COM Exceptions.
    Tuesday, July 19, 2011 9:11 AM
  • I'm running into the same issue. What is the solution here? How did you ensure you have full control for all web apps?

    Thursday, September 8, 2011 8:27 PM
  • Yes. Go inside Manage Web Apps and then grant the user Full rights to the web app. If you have any code which iterates of all the sites in your envionrment, then that user id should have FUll control over the web apps.

    Monday, September 12, 2011 9:44 AM
  • The account will need permissions on the content database. Just executing:

    Add-SPShellAdmin CONTOSO\User1

    Will give you access to the configuration database, but not the content database. Also provide access to the content database by giving access to the content database by using the -database parameter

    Add-SPShellAdmin -UserName CONTOSO\User1 -database 4251d855-3c15-4501-8dd1-98f960359fa6

    You can offcourse provide access to all content databases and SharePoint service application databases by using a command like:

    Get-SPDatabase | Add-SPShellAdmin CONTOSO\User1

    Wednesday, April 18, 2012 7:50 AM
  • yes.... but content databases are added to the farm as time goes on.

    So as part of adding the content database, we should also have a process where the fram account gets the spshelladmin access on the new content database.

    which I find funny. ideally this should be automatic when I create a new content database


    MSDNStudent Knows not much!

    Friday, April 20, 2012 7:40 PM
  • Yes, it worked for me.

    Thank you so much. It saved my day.

    Wednesday, August 14, 2019 10:21 AM