From b1b179418b6b603ec2340c55389202223911d548 Mon Sep 17 00:00:00 2001 From: Fabian Bader Date: Sun, 21 Jul 2024 21:49:52 +0200 Subject: [PATCH 1/2] Add dummy Invoke to verify credentials are valid --- powershell/public/core/Test-MtConnection.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/powershell/public/core/Test-MtConnection.ps1 b/powershell/public/core/Test-MtConnection.ps1 index 833c5737..a115c6e8 100644 --- a/powershell/public/core/Test-MtConnection.ps1 +++ b/powershell/public/core/Test-MtConnection.ps1 @@ -33,7 +33,10 @@ function Test-MtConnection { $isConnected = $false try { $isConnected = $null -ne (Get-AzContext -ErrorAction SilentlyContinue) + # Validate that the credentials are still valid + Invoke-AzRestMethod -Method GET -Path "subscriptions" -ErrorAction Stop | Out-Null } catch { + $isConnected = $false Write-Debug "Azure: $false" } Write-Verbose "Azure: $isConnected" From 3a515c8d0e3158fa6e031bad4f4b497e111ce01f Mon Sep 17 00:00:00 2001 From: Fabian Bader Date: Sun, 21 Jul 2024 21:50:17 +0200 Subject: [PATCH 2/2] chore: Update Azure AD diagnostic settings API calls to use GET method --- .../public/cisa/entra/Test-MtCisaDiagnosticSettings.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powershell/public/cisa/entra/Test-MtCisaDiagnosticSettings.ps1 b/powershell/public/cisa/entra/Test-MtCisaDiagnosticSettings.ps1 index efb19ab1..10c6b534 100644 --- a/powershell/public/cisa/entra/Test-MtCisaDiagnosticSettings.ps1 +++ b/powershell/public/cisa/entra/Test-MtCisaDiagnosticSettings.ps1 @@ -24,7 +24,7 @@ function Test-MtCisaDiagnosticSettings { return $null } - $logs = Invoke-AzRestMethod -Path "/providers/microsoft.aadiam/diagnosticSettingsCategories?api-version=2017-04-01-preview" + $logs = Invoke-AzRestMethod -Method GET -Path "/providers/microsoft.aadiam/diagnosticSettingsCategories?api-version=2017-04-01-preview" $logs = ($logs.Content|ConvertFrom-Json).value $logs = ($logs | Where-Object { ` $_.properties.categoryType -eq "Logs" @@ -32,7 +32,7 @@ function Test-MtCisaDiagnosticSettings { $configs = @() - $settings = Invoke-AzRestMethod -Path "/providers/microsoft.aadiam/diagnosticSettings?api-version=2017-04-01-preview" + $settings = Invoke-AzRestMethod -Method GET -Path "/providers/microsoft.aadiam/diagnosticSettings?api-version=2017-04-01-preview" $settings = ($settings.Content|ConvertFrom-Json).value $settings | ForEach-Object { `