Jul 12 2019 07:56 AM - edited Jul 12 2019 07:59 AM
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
}
Jul 13 2019 12:25 AM
SolutionJul 13 2019 04:03 AM - edited Jul 13 2019 04:08 AM
@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.
Jul 13 2019 04:40 AM
Jul 15 2019 02:39 AM - edited Jul 15 2019 02:40 AM
@Deleted you are right. I never know when and where to post these types of issue. In my case I assume that it is something I am not doing correctly before considering an SPIssue 😑.
I have some findings:
This syntax works but you get presented with the login dialog each time you need to connect. Note, you can't use -UseWebLogin with this combinations of parameters.
Connect-PnPOnline -Url $auditItem.SiteUrl -ClearTokenCache -SPOManagementShell
If you want to speedily connect to various site collections without always being presented with the login dialog, then I recommend this syntax - was able to pass my list of OneDrive Urls with just a slight pause to establish each connection.
Connect-PnPOnline -Url $auditItem.SiteUr -SPOManagementShell
Jul 13 2019 12:25 AM
Solution