Repository navigation
Get ResourceGroupCost
Retrieves the Azure costs for one or more billing months for one or more resource groups.
Get-ResourceGroupCost [[-ResourceGroupName] <String[]>] [[-SubscriptionName] <String[]>]
[[-BillingMonth] <DateTime>] [[-PreviousMonths] <Int32>] [[-SparkLineSize] <Int32>] [-ComparePrevious]
[[-ComparePreviousOffset] <Int32>] [-ExcludeSparklines] [-Raw] [-EaSubscription]
[[-EaSubscriptionKind] <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
Invokes the Get-AzConsumptionUsageDetail cmdlet and groups the results by resource group to return billing data for a specified number of months. If you are interested to see how costs have changed since the previous month use the -ComparePrevious switch to return additional properties that contain the cost data for the previous month and properties that calculate the cost difference. Specify multiple resource group names to return an object for each so that their costs can be compared against each other. When one or more resource group names are specified, each is queried directly (filtered server-side) rather than pulling every resource in the subscription and filtering locally, which is significantly faster. If no resource group name is specified every resource group in the billing data is discovered and returned instead, which requires an unfiltered pull.
Get-ResourceGroupCost
Returns costs for the current billing month for every Resource Group found in the current Azure context's billing data.
Get-ResourceGroupCost -ResourceGroupName 'MyResourceGroup'
Returns costs for the current billing month for the specified Resource Group name.
Get-ResourceGroupCost -ResourceGroupName 'MyResourceGroupA','MyResourceGroupB'
Returns costs for the current billing month for the specified Resource Group names, so that they can be compared against each other.
Get-ResourceGroupCost -ResourceGroupName 'MyResourceGroup' -SubscriptionName 'MySubscriptionA','MySubscriptionB'
Returns costs for the current billing month for the specified Resource Group name, queried within each of the specified subscriptions.
Get-ResourceGroupCost -BillingMonth 01/2024 -PreviousMonths 3
Returns costs from October 2023 to January 2024 for every Resource Group found in the current Azure context's billing data.
Get-ResourceGroupCost -BillingMonth 01/2024 -PreviousMonths 3 -ComparePrevious
Returns costs from October 2023 to January 2024 for every Resource Group found in the current Azure context's billing data and includes properties for comparing each month with the one prior.
Get-ResourceGroupCost -BillingMonth 01/2024 -PreviousMonths 3 -ComparePrevious -ComparePreviousOffset 12
Returns costs from October 2023 to January 2024 for every Resource Group found in the current Azure context's billing data and includes properties for comparing each month with the one 12 months prior
The name or name/s of the Resource Group/s to query. If not specified every resource group found in the billing data will be used.
Type: String[]
Parameter Sets: (All)
Aliases: Name, RG
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe name or name/s of the Subscription/s to query the Resource Group/s within. If not specified the current Azure context's subscription is used.
Type: String[]
Parameter Sets: (All)
Aliases: Subscription
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe billing month to query for cost data, specified as a [datetime] object. You can specify just month/year, e.g 10/2023. If not specified uses the current date.
Type: DateTime
Parameter Sets: (All)
Aliases: Month
Required: False
Position: 3
Default value: (Get-Date)
Accept pipeline input: False
Accept wildcard characters: FalseThe number of previous billing months to query. Default: 0.
Type: Int32
Parameter Sets: (All)
Aliases: PrevMonths
Required: False
Position: 4
Default value: 0
Accept pipeline input: False
Accept wildcard characters: FalseThe row height of sparklines to generate (requires PSparkines module). Default: 1.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: 1
Accept pipeline input: False
Accept wildcard characters: FalseSwitch: Include values for the previous billing month and adds additional properties that compare the current month to the previous.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: ComparePrev
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThe number of months prior you want to compare the current billing month to, when using -ComparePrevious, e.g set to 3 to compare to 3 months prior.
Type: Int32
Parameter Sets: (All)
Aliases: ComparePrevOffset
Required: False
Position: 6
Default value: 0
Accept pipeline input: False
Accept wildcard characters: FalseSwitch: Do not generate/include Sparklines in the output.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSwitch: Include the raw cost consumption data as a property on the returned object.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSwitch: Force use of alternative consumption collection script for Enterprise Agreement subscriptions.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecify the kind of Enterprise Agreement, modern or legacy. Default: modern.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: Modern
Accept pipeline input: False
Accept wildcard characters: False{{Fill ProgressAction Description}}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).