From 50d69613777427c0018180c76d4e64910f5ba724 Mon Sep 17 00:00:00 2001 From: Pim Simons Date: Wed, 23 Aug 2023 11:04:05 +0200 Subject: [PATCH 1/2] conditionally use securestring for `Connect-MgGraph` --- .../Connect-MgGraphFromConfig.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Arcus.Scripting.Tests.Integration/Connect-MgGraphFromConfig.ps1 b/src/Arcus.Scripting.Tests.Integration/Connect-MgGraphFromConfig.ps1 index 0f216613..f82fe04a 100644 --- a/src/Arcus.Scripting.Tests.Integration/Connect-MgGraphFromConfig.ps1 +++ b/src/Arcus.Scripting.Tests.Integration/Connect-MgGraphFromConfig.ps1 @@ -17,4 +17,11 @@ $connection = Invoke-RestMethod ` $token = $connection.access_token -Connect-MgGraph -AccessToken $token \ No newline at end of file +$targetParameter = (Get-Command Connect-MgGraph).Parameters['AccessToken'] + +if ($targetParameter.ParameterType -eq [securestring]){ + Connect-MgGraph -AccessToken ($token |ConvertTo-SecureString -AsPlainText -Force) +} +else { + Connect-MgGraph -AccessToken $token +} \ No newline at end of file From bcb269e1d4b8741647e5c12a95a6354a09dee094 Mon Sep 17 00:00:00 2001 From: Pim Simons <32359437+pim-simons@users.noreply.github.com> Date: Wed, 23 Aug 2023 11:52:25 +0200 Subject: [PATCH 2/2] Update src/Arcus.Scripting.Tests.Integration/Connect-MgGraphFromConfig.ps1 Co-authored-by: Stijn Moreels <9039753+stijnmoreels@users.noreply.github.com> --- .../Connect-MgGraphFromConfig.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Arcus.Scripting.Tests.Integration/Connect-MgGraphFromConfig.ps1 b/src/Arcus.Scripting.Tests.Integration/Connect-MgGraphFromConfig.ps1 index f82fe04a..9357bf51 100644 --- a/src/Arcus.Scripting.Tests.Integration/Connect-MgGraphFromConfig.ps1 +++ b/src/Arcus.Scripting.Tests.Integration/Connect-MgGraphFromConfig.ps1 @@ -19,7 +19,7 @@ $token = $connection.access_token $targetParameter = (Get-Command Connect-MgGraph).Parameters['AccessToken'] -if ($targetParameter.ParameterType -eq [securestring]){ +if ($targetParameter.ParameterType -eq [securestring]) { Connect-MgGraph -AccessToken ($token |ConvertTo-SecureString -AsPlainText -Force) } else {