Skip to content

Instantly share code, notes, and snippets.

@SibeeshVenu
Created May 20, 2022 15:58
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 SibeeshVenu/a735db3439ca50305a5141ab83d26892 to your computer and use it in GitHub Desktop.
Save SibeeshVenu/a735db3439ca50305a5141ab83d26892 to your computer and use it in GitHub Desktop.
PowerShell function to get the metadata of all the blobs inside the Azure storage container!
# Set the Execution policy for the current session
# Set-ExecutionPolicy -ExecutionPolicy ByPass -Scope Process
$containerName = ''
$subscriptionid = ''
$storageAccName = ''
Function GetAllBlobMetadata
{
# Connect to your Azure subscription
Connect-AzAccount -Subscription $subscriptionid
# Create a context object using Azure AD credentials
$ctx = New-AzStorageContext -StorageAccountName $storageAccName -UseConnectedAccount
# Get blobs
$blobs = Get-AzStorageBlob -Container $containerName -Context $ctx
## Loop through all the blobs
foreach($blob in $blobs)
{ $blobName = $blob.Name
$blob = Get-AzStorageBlob -Blob $blobName -Container $containerName -Context $ctx
$properties = $blob.BlobClient.GetProperties()
Write-Output "The metadata for the blob {$blobName}: "
Write-Output $properties.Value
}
}
GetAllBlobMetadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment