Skip to content

Get-ConsumptionUsageDetail

Azure: Gets Azure consumption usage details

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

	[Parameter(Mandatory = $false)]
	[int]$Top
)

try {
	Import-Module Az.Consumption -ErrorAction Stop
	
	[hashtable]$cmdArgs = @{ 'ErrorAction' = 'Stop' }
	if ($BillingPeriodName) { $cmdArgs.Add('BillingPeriodName', $BillingPeriodName) }
	if ($Top) { $cmdArgs.Add('MaxCount', $Top) }

	$usage = Get-AzConsumptionUsageDetail @cmdArgs
	Write-Output $usage
} catch {
	Write-Error $_
	exit 1
}

The name of the billing period (optional).

The maximum number of records to return (optional).

An interactive directory of PowerShell scripts.