Skip to content

Get-StorageAccount

Azure: Gets Azure storage accounts

param(
	[Parameter(Mandatory = $false)]
	[string]$ResourceGroupName,

	[Parameter(Mandatory = $false)]
	[string]$Name
)

try {
	Import-Module Az.Storage -ErrorAction Stop
	
	[hashtable]$cmdArgs = @{ 'ErrorAction' = 'Stop' }
	if ($ResourceGroupName) { $cmdArgs.Add('ResourceGroupName', $ResourceGroupName) }
	if ($Name) { $cmdArgs.Add('Name', $Name) }

	$accounts = Get-AzStorageAccount @cmdArgs
	Write-Output $accounts
} catch {
	Write-Error $_
	exit 1
}

The name of the resource group (optional).

The name of the storage account (optional).

An interactive directory of PowerShell scripts.