-
-
Save kaioken/19527c9451346fd85bf0d7c61628fee1 to your computer and use it in GitHub Desktop.
PowerShell script to iterate all containers and blobs in a storage account and download it.
This file contains hidden or 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
$destination_path = 'C:\Users\dilli\Downloads\media_dump' | |
$connection_string = '[AZURE_STORAGE_CONNECTION_STRING]' | |
$storage_account = New-AzureStorageContext -ConnectionString $connection_string | |
$containers = Get-AzureStorageContainer -Context $storage_account | |
Write-Host 'Starting Storage Dump...' | |
foreach ($container in $containers) | |
{ | |
Write-Host -NoNewline 'Processing: ' . $container.Name . '...' | |
$container_path = $destination_path + '\' + $container.Name | |
if(!(Test-Path -Path $container_path )) | |
{ | |
New-Item -ItemType directory -Path $container_path | |
} | |
$blobs = Get-AzureStorageBlob -Container $container.Name -Context $storage_account | |
Write-Host -NoNewline ' Downloading files...' | |
foreach ($blob in $blobs) | |
{ | |
$fileNameCheck = $container_path + '\' + $blob.Name | |
if(!(Test-Path $fileNameCheck )) | |
{ | |
Get-AzureStorageBlobContent ` | |
-Container $container.Name -Blob $blob.Name -Destination $container_path ` | |
-Context $storage_account | |
} | |
} | |
Write-Host ' Done.' | |
} | |
Write-Host 'Download complete.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment