# Desc: Connect to a SAS URL blob container and iterate through all the files. # Saves a numbered csv file for each 5000 files. Easy on RAM even for containers with millions of files # CSV file contains: FileName, FilePath, FileSizeBytes # ================================ # Settings # ================================ Clear-Host $containerSasUrl = "https://my-storage-acct.blob.core.windows.net/my-container?sp=rl&st=2025-08-13T19:48:50Z&se=2025-08-22T04:03:50Z&spr=https&sv=2024-11-04&sr=c&sig=***********" $outputDir = "C:\logs" $chunkSize = 5000 # ================================ # Vars # ================================ $chunkIndex = 1 $rowBuffer = @() $marker = "" $totalCount = 0 # ================================ $StartDate = Get-Date Write-Host "Started: $(($StartDate).ToString('yyyy-MM-dd HH:mm:ss'))" # Ensure output directory exists if (-not (Test-Path $outputDir)) { New-Item -Path $outputDir -ItemType Directory | Out-Null } do { $url = "$containerSasUrl&restype=container&comp=list&maxresults=5000" if ($marker) { $url += "&marker=$marker" } Write-Host "Getting chunk $chunkIndex with marker: $marker" # Use Invoke-WebRequest to get raw content $rawContent = (Invoke-WebRequest -Uri $url -UseBasicParsing).Content $cleanXml = $rawContent -replace "^[^\<]+","" # Strip any junk characters before