Created
June 4, 2024 20:44
-
-
Save joerodgers/4cee5fab91fe5c6cb6f39ab5cb0fafd8 to your computer and use it in GitHub Desktop.
Exports Loop Workspace Data to CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Connect-SPOService -Url "https://contoso-admin.sharepoint.com" | |
$counter = 1 | |
$token = $null | |
$containers = do | |
{ | |
Write-Host "[$(Get-Date)] - Fetching Containers page: $counter" | |
$containers = if( -not $token ) | |
{ | |
Get-SPOContainer -OwningApplicationId "a187e399-0c36-4b98-8f04-1edc167a0996" -Paged | |
} | |
else | |
{ | |
Get-SPOContainer -OwningApplicationId "a187e399-0c36-4b98-8f04-1edc167a0996" -Paged -PagingToken $token | |
} | |
if( $containers[-1] -match "Retrieve remaining containers with token" ) | |
{ | |
$token = $containers[-1] -replace "Retrieve remaining containers with token: ", "" | |
Write-Host "[$(Get-Date)] - Containers page Token: $token" | |
} | |
else | |
{ | |
$token = $null | |
} | |
$containers | Select-Object * -SkipLast 1 | |
$counter++ | |
} | |
while( $null -ne $token ) | |
$containerDetails = foreach( $container in $containers ) | |
{ | |
Get-SPOContainer -Identity $container.ContainerId | |
} | |
$containerDetails | Sort-Object -Property CreatedOn -Descending | Select-Object * | Export-Csv -Path "C:\_temp\loopcontainerdetails.csv" -NoTypeInformation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment