Am trying to get report of alerts fired in past 14 days from a resource group in Azure through PowerShell, The below code is running but the output of excel is blank.
Get-AzAlert -TargetResourceGroup xxxxxxx | Export-Excel -Path C:UsersnameDownloadsa.xlsx
$filterDate=(Get-Date).AddDays(-14)
Tried the above code, but the output of excel is blank.
2
Answers
Thanks guys, got the output successfully with this query:
To get a PowerShell report of alerts fired in the last 14 days from an Azure resource group:
Try below script and it worked for me as follows:
Output:
You can also obtain metrics for a particular time range by providing
-CustomTimeRange
parameter which includes starttime and endtime and clearly detailed in MSDoc.