Last active
November 24, 2015 15:12
-
-
Save jeffpatton1971/c326b430ab734c9123c2 to your computer and use it in GitHub Desktop.
Get a file from an azure container
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
Param | |
( | |
[Parameter(Mandatory=$true)] | |
[string]$ResourceGroupName, | |
[Parameter(Mandatory=$false)] | |
[string]$StorageAccountName, | |
[Parameter(Mandatory=$true)] | |
[string]$ContainerName, | |
[Parameter(Mandatory=$true)] | |
[string]$Path | |
) | |
try | |
{ | |
$ErrorActionPreference = "Stop" | |
$Error.Clear() | |
$AzureStorageAccount = Get-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName | |
$AzureStorageContext = $AzureStorageAccount.Context | |
$AzureStorageContainer = Get-AzureStorageContainer -Name $ContainerName -Context $AzureStorageContext | |
$CloudBlobContainers = $AzureStorageContainer.CloudBlobContainer.ListBlobs() | |
foreach ($CloudBlobContainer in $CloudBlobContainers) | |
{ | |
Get-AzureRmStorageBlobContent -CloudBlob $CloudBlobContainer -Destination $Path -Context $AzureStorageContainer.Context | |
} | |
} | |
catch | |
{ | |
throw $Error | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment