In this article, you will see how to get all Storage Accounts using PowerShell.
Install the Azure PowerShell Module:
Open Windows PowerShell window and run the below command.
Install-Module -Name Az –AllowClobber
![](https://static.wixstatic.com/media/0b3d63_853dcf7d9f374dd09b4360557f14ffee~mv2.png/v1/fill/w_49,h_10,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/0b3d63_853dcf7d9f374dd09b4360557f14ffee~mv2.png)
Get All Storage Accounts:
Open a text file. Copy and paste the below script. Save the file as script.ps1.
################# Azure Blob Storage - PowerShell ####################
## Input Parameters
$resourceGroupName="psspschennairg"
## Connect to Azure Account
Connect-AzAccount
## Function to get all the storage accounts
Function GetAllStorageAccount
{
Write-Host -ForegroundColor Green "Retrieving the storage accounts..."
## Get the list of Storage Accounts
$storageAccColl=Get-AzStorageAccount
foreach($storageAcc in $storageAccColl)
{
write-host -ForegroundColor Yellow $storageAcc.StorageAccountName
}
Write-Host -ForegroundColor Green "Retrieving the storage accounts from specific resource group..."
## Get the list of Storage Accounts from specific resource group
$storageAccCollRG=Get-AzStorageAccount -ResourceGroupName $resourceGroupName
foreach($storageAcc in $storageAccCollRG)
{
write-host -ForegroundColor Yellow $storageAcc.StorageAccountName
}
}
GetAllStorageAccount
## Disconnect from Azure Account
Disconnect-AzAccount
######################################################################
Open Windows PowerShell window and navigate to the location where the script file was saved.
Run the following command.
.\script.ps1
![](https://static.wixstatic.com/media/0b3d63_e2c864eac16d46e7959c51099c30799d~mv2.png/v1/fill/w_49,h_14,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/0b3d63_e2c864eac16d46e7959c51099c30799d~mv2.png)
Summary:
Thus in this article you saw how to get all Azure Storage Accounts using PowerShell.