From 9efec1bb948cb7402ac5a608e3aa26af1955ad01 Mon Sep 17 00:00:00 2001 From: Takeshi Katano Date: Thu, 19 Sep 2024 00:07:33 +0900 Subject: [PATCH] fix: Fix 'n/a' resource id handing in resource type counting (#397) --- tools/3_wara_reports_generator.ps1 | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/3_wara_reports_generator.ps1 b/tools/3_wara_reports_generator.ps1 index 330618631..039e916d8 100644 --- a/tools/3_wara_reports_generator.ps1 +++ b/tools/3_wara_reports_generator.ps1 @@ -268,11 +268,22 @@ $Global:Runtime = Measure-Command -Expression { { if (![string]::IsNullOrEmpty($ID)) { - $obj = @{ - 'ID' = $ID; - 'Subscription' = $ID.split('/')[2]; - 'Resource Group' = $ID.split('/')[4]; - 'Resource Type' = ($ID.split('/')[6] + '/' + $ID.split('/')[7]) + if ($ID -eq 'n/a') { + # Need special care for the recommendation 4e133bd0-8762-bc40-a95b-b29142427d73 because it returns 'n/a' as resource IDs. + $obj = @{ + 'ID' = $ID + 'Subscription' = 'n/a' + 'Resource Group' = 'n/a' + 'Resource Type' = 'Microsoft.Network/networkWatchers' + } + } + else { + $obj = @{ + 'ID' = $ID; + 'Subscription' = $ID.split('/')[2]; + 'Resource Group' = $ID.split('/')[4]; + 'Resource Type' = ($ID.split('/')[6] + '/' + $ID.split('/')[7]) + } } $Resources += $obj }