From 92311ffa104110645cb8d22ed531cfec29dfbea4 Mon Sep 17 00:00:00 2001 From: Freddy Kristiansen Date: Wed, 18 Oct 2023 05:47:42 -0700 Subject: [PATCH] fix accesstoken type (#3211) Co-authored-by: freddydk --- AzureAD/New-AadAppsForBc.ps1 | 16 ++++++++++------ ReleaseNotes.txt | 3 +++ Version.txt | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/AzureAD/New-AadAppsForBc.ps1 b/AzureAD/New-AadAppsForBc.ps1 index 99f73b2df..4b15f7b0d 100644 --- a/AzureAD/New-AadAppsForBc.ps1 +++ b/AzureAD/New-AadAppsForBc.ps1 @@ -79,16 +79,20 @@ try { if ($jwtToken.aud -ne 'https://graph.microsoft.com') { Write-Host -ForegroundColor Yellow "The accesstoken was provided for $($jwtToken.aud), should have been for https://graph.microsoft.com" } - Connect-MgGraph -AccessToken $bcAuthContext.accessToken | Out-Null + $accessToken = $bcAuthContext.accessToken } - else { - if ($accessToken) { - Connect-MgGraph -accessToken $accessToken | Out-Null + if ($accessToken) { + try { + # Connect-MgGraph changed type of accesstoken parameter from plain text to securestring along the way + Connect-MgGraph -accessToken (ConvertTo-SecureString -String $accessToken -AsPlainText -Force) | Out-Null } - else { - Connect-MgGraph -Scopes 'Application.ReadWrite.All' | Out-Null + catch [System.ArgumentException] { + Connect-MgGraph -accessToken $accessToken | Out-Null } } + else { + Connect-MgGraph -Scopes 'Application.ReadWrite.All' | Out-Null + } } $account = Get-MgContext diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 5e56ad3e1..c633006ee 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,3 +1,6 @@ +6.0.1 +New-AadAppsForBC doesn't work with the newer versions of Microsoft.Graph module (where the type of the accesstoken parameter has changed) + 6.0.0 Add parameter -accept_insiderEULA on New-BcContainer, Get-BcArtifactUrl and Run-AlPipeline to accept the insider EULA (https://go.microsoft.com/fwlink/?linkid=2245051) instead of using the insider SAS token. The insider SAS token is still supported until April 2024 where the last insider SAS token will expire... diff --git a/Version.txt b/Version.txt index 2911f7764..b33d46263 100644 --- a/Version.txt +++ b/Version.txt @@ -1 +1 @@ -6.0.0-dev +6.0.1-dev