I'm trying to get the usage details for an azure subscription in JSON format through powershell and rest API(https://consumption.azure.com/v3/enrollments/{enrollmentNumber}/usagedetailsbycustomdate?startTime=2017-01-01&endTime=2017-01-10)
My code is working when I use actual values of date as parameter. But when I use variables to get the current and previous day's date it doesn't work. It is throwing an error saying the value is less than 2014-05-01
$endDate = Get-Date
$startDate = $endDate.AddDays(-1)`enter code here`
$out = $startDate.ToString('yyyy-MM-dd')
$out1 = $endDate.ToString('yyyy-MM-dd')
$header = @{"authorization"="bearer $key"}
$uri = "https://consumption.azure.com/v3/enrollments/$enrollment/usagedetailsbycustomdate?startTime=$out&endTime=$out1"
I'm looking to get the last two days of usage details through this code. Any help or advise is appreciated