Forum Discussion

Daniel Westerdale's avatar
Daniel Westerdale
Iron Contributor
Jul 16, 2019
Solved

OneDrive + Get-PnPRecycleBinItem : Access denied. You do not have permission

Hi

 

Firstly, I   am not sure this bug or by design 🤔 however, it is impeding my progress.

 

Anyway, I am looking to initially, review the deleted files in a set of User's  ODFB  recycle bins. To do this I thought the best approach is PowerShell. 

 

 

# connect to the user's ODFB

Connect-PnPOnline -Url $ODFBUserUrl -SPOManagementShell # -UseWebLogin

Write-Host -ForegroundColor Blue (Get-PnPSite).Url

Get-PnPRecycleBinItem | Select-object -First 100 Title, DirName, DeletedByName, DeletedDate, DeletedDateLocalFormatted
Unfortunately, I get faced with a limiting error:

Get-PnPRecycleBinItem : Access denied. You do not have permission to perform this action or access this resource.

 

I am an Office 365 global & SharePoint admin and I have even added myself as the MySIte Secondary Admin:

However I am still hitting this permissions issue.  Do I need to add myself as a site collection admin to the OneDrive of each user - assuming I have permissions to do that.

  • I believe the Secondary admin setting you have pictured only applies to new My Sites.

     

    For existing My Sites/OneDrive sites, you will probably have to add yourself directly as a Site Collection Admin for the ones you are trying to access.

2 Replies

  • I believe the Secondary admin setting you have pictured only applies to new My Sites.

     

    For existing My Sites/OneDrive sites, you will probably have to add yourself directly as a Site Collection Admin for the ones you are trying to access.

    • Daniel Westerdale's avatar
      Daniel Westerdale
      Iron Contributor

      kevinmckeown8  You are 100% correct.  

       

      Located, https://gallery.technet.microsoft.com/How-to-add-a-secondary-0b878d98?redir=0

       

      From this I simply added:

       

      Set-SPOUser -LoginName $ODFBSecondaryAdmin -Site $ODFBUserUrl -IsSiteCollectionAdmin $True
      Then I am able to inspect each user's Recycle bin and filter by Deleted Date as desired. Happy days!

Resources