@Chris Moceri - Thanks for the question and using MS Q&A paltform.
Yes, you can use the Azure PowerShell module to get a list of all your reservations in USWest and USWest2 that are in a provisioned state of Succeeded (or not archived), along with their remaining cost or cancellation fee. Here's an example PowerShell script that you can use:
# Connect to your Azure account
Connect-AzAccount
# Set the subscription context
Set-AzContext -SubscriptionId <SubscriptionId>
# Get all reservations in USWest and USWest2 that are in a provisioned state of Succeeded (or not archived)
$reservations = Get-AzReservation `
-Location "USWest","USWest2" `
-State "Succeeded" `
-IncludeExpired $false `
-IncludeChildren $false `
-ApiVersion "2018-01-31"
# Loop through each reservation and get its remaining cost or cancellation fee
foreach ($reservation in $reservations) {
$reservationOrderId = $reservation.ReservationOrderId
$reservationId = $reservation.Id
$remainingCost = Get-AzReservationUsage `
-ReservationOrderId $reservationOrderId `
-ReservationId $reservationId `
-ApiVersion "2018-01-31" `
| Where-Object { $_.Name -eq "RemainingCost" } `
| Select-Object -ExpandProperty Quantity
$cancellationFee = Get-AzReservation `
-ReservationOrderId $reservationOrderId `
-ReservationId $reservationId `
-ApiVersion "2018-01-31" `
| Select-Object -ExpandProperty CancellationFee
Write-Output "Reservation: $($reservation.Name), Remaining Cost: $($remainingCost), Cancellation Fee: $($cancellationFee)"
}
This script first connects to your Azure account and sets the subscription context. It then uses the Get-AzReservation
cmdlet to get all reservations in USWest and USWest2 that are in a provisioned state of Succeeded (or not archived). Finally, it loops through each reservation and uses the Get-AzReservationUsage
and Get-AzReservation
cmdlets to get its remaining cost or cancellation fee.
Note that you may need to modify the script to fit your specific needs, such as filtering by reservation type or scope. Also, make sure that you have the latest version of the Azure PowerShell module installed.
For more details, refer to Manage Reservations for Azure resources.
Hope this helps. Do let us know if you any further queries.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.