Forum Discussion

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

Best way to run Get-PNPRecycleBInItems against multiple OneDrives and with 2FA

 

Hi 

 

I have been asked to audit the retention policies applied to bunch of test user's ODFB document libraries.   Hence, looking to review the recycle bins of each user  ( I think the primary bin is scoped to the site and the secondary is at the site collection level) .

 

with this in mind I  am currently using the snippet below, in that I am trying to get around the issue when my first 2FA connection goes through ok but subsequent connections fail because I presented with a nice blank 2FA dialog and VSCode just freezes.  Indeed I end up having to to restart the PS session in VSCode. If there is a better way to parse these recycle bins, I am all ears!

 

$retnConnection = $null

foreach($auditItem in $auditItems)

{

Write-Host $auditItem.SiteName " " $auditItem.SiteUrl

$ODFBDocumentLibaryUrl = $ODFBBaseUrl + $auditItem.DocumentLibaryUrl

Write-Host -ForegroundColor DarkYellow $ODFBDocumentLibraryUrl

If ($retnConnection)

{

Disconnect-PnPOnline

}

# connect to the user's ODFB

$retnConnection = Connect-PnPOnline -Url $auditItem.SiteUrl -UseWebLogin -ReturnConnection

Get-PnPRecycleBinItem -SecondStage | Select-object -First 100 Title, DirName, DeletedByName, DeletedDate, DeletedDateLocalFormatted

}

 

  • Anonymous's avatar
    Anonymous
    Jul 13, 2019
    What happens if you add -ClearTokenCache -SPOManagementShell after -UseWebLogin?

    Does it progress further than the blank screen?

4 Replies

  • Anonymous's avatar
    Anonymous
    What happens if you add -ClearTokenCache -SPOManagementShell after -UseWebLogin?

    Does it progress further than the blank screen?
    • Daniel Westerdale's avatar
      Daniel Westerdale
      Iron Contributor

      Deleted  Thanks for your response.  I have always wondered about these additional parameters. Will try this first thing on Monday  and report back. BTW for reference, this the  " white screen of death"   I have been encountering.

      • Anonymous's avatar
        Anonymous
        No problem at all, it sounds like this issue which a few others have come up against.

        https://github.com/SharePoint/PnP-PowerShell/issues/1744

Resources