Public/Curanet/M365/Get-CuranetM365AzureBilling.ps1
function Get-CuranetM365AzureBilling() { Param( [Parameter(Mandatory)] [ValidateSet("3370", "3850")] [string]$Account, [Parameter(Mandatory)] [DateTime]$StartDate, [Parameter(Mandatory)] [DateTime]$EndDate, [Parameter] [string]$SubscriptionId ) $Body = @{ startDate = $StartDate endDate = $EndDate costType = "Usage" timeFrame = "Custom" splitCostInCategories = $true } try { if($SubscriptionId) { $AzureBilling = Invoke-CuranetAPI -Account $Account -Uri "https://api.curanet.dk/microsoft365/v1/Subscriptions/$($SubscriptionId)/AzureBilling/Query" -Method POST -Body $Body } else { $AzureBilling = Invoke-CuranetAPI -Account $Account -Uri "https://api.curanet.dk/microsoft365/v1/AzureBilling/Query" -Method POST -Body $Body } } catch { throw "Failed to retreive Azure Billing from Curanet $($Account) API: $_" } return $AzureBilling } |