Created
May 20, 2022 15:58
-
-
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!
This file contains 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
# 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