Skip to content

Get-ResourceGroup

Azure: Gets resource groups

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

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

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

	$rgs = Get-AzResourceGroup @cmdArgs
	Write-Output $rgs
} catch {
	Write-Error $_
	exit 1
}

The name of the resource group (optional).

The location of the resource group (optional).

An interactive directory of PowerShell scripts.