Quickly see all storage keys for Azure Storage accounts

Quickly see all storage keys for Azure Storage accounts

Q. How can I quickly see the primary key to access all storage accounts I have access to?

A. I recently wanted to setup a graphical tool to view all my storage accounts which requires knowing the storage account name and storage key. This information can be found in the Azure portal however I hada lot of storage accounts so the PowerShell below quickly shows all the storage accounts and their respective keys. Please be careful with the output and do not share as anyone with this information can access your storage accounts.

#Get key of storage account
$storaccounts=Get-AzureStorageAccount
foreach($storaccount in $storaccounts)
{
    $Key=Get-AzureStorageKey $storaccount.Label
    $outputtext = $storaccount.Label + "`t" + $key.Primary
    write-output $outputtext
}

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish