Skip to content

Instantly share code, notes, and snippets.

@joerodgers
Created June 4, 2024 20:44
Show Gist options
  • Save joerodgers/4cee5fab91fe5c6cb6f39ab5cb0fafd8 to your computer and use it in GitHub Desktop.
Save joerodgers/4cee5fab91fe5c6cb6f39ab5cb0fafd8 to your computer and use it in GitHub Desktop.
Exports Loop Workspace Data to CSV
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