Skip to content

Instantly share code, notes, and snippets.

@jeffpatton1971
Last active November 24, 2015 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffpatton1971/c326b430ab734c9123c2 to your computer and use it in GitHub Desktop.
Save jeffpatton1971/c326b430ab734c9123c2 to your computer and use it in GitHub Desktop.
Get a file from an azure container
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