From 08a7c4e701ad3f11225b20e57b7f6ede846f0605 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Wed, 26 Oct 2022 12:09:05 -0400 Subject: [PATCH 1/2] Fixes #2447 --- CHANGELOG.md | 2 ++ Modules/Microsoft365DSC/Modules/M365DSCReverse.psm1 | 4 +++- Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 806a854c6e..bde2f6783f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ * Updated MSCloudLoginAssistant to version 1.0.96; * MISC * Add support for ManagedIdentity to the SPo and OD resources. + * Fixed and issue with Export and ApplicationSecret where it wasn't properly converting to a PSCredential. + * FIXES [#2447](https://github.com/microsoft/Microsoft365DSC/issues/2447) # 1.22.1019.1 diff --git a/Modules/Microsoft365DSC/Modules/M365DSCReverse.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCReverse.psm1 index feb54d2578..57a29564ee 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCReverse.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCReverse.psm1 @@ -234,10 +234,12 @@ function Start-M365DSCConfigurationExtract $AuthMethods -contains 'CertificatePath' -or ` $AuthMethods -contains 'ApplicationWithSecret') { + [SecureString]$secStringPassword = ConvertTo-SecureString $ApplicationSecret -AsPlainText -Force + [PSCredential]$AppSecretAsPSCredential = New-Object System.Management.Automation.PSCredential ('ApplicationSecret', $secStringPassword) $organization = Get-M365DSCTenantDomain -ApplicationId $ApplicationId ` -TenantId $TenantId ` -CertificateThumbprint $CertificateThumbprint ` - -ApplicationSecret $ApplicationSecret ` + -ApplicationSecret $AppSecretAsPSCredential ` -CertificatePath $CertificatePath } elseif ($AuthMethods -Contains 'Credentials') diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index 8300c41805..180d2d50bf 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -1376,7 +1376,7 @@ function Get-M365DSCTenantDomain $TenantId, [Parameter(ParameterSetName = 'AppId')] - [System.String] + [System.Management.Automation.PSCredential] $ApplicationSecret, [Parameter(ParameterSetName = 'AppId')] From 9f4f29120219092a70f95b8fcb5369f69903ef2f Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Wed, 26 Oct 2022 12:10:20 -0400 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c51856d0c..d7e0cedc42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ * DEPENDENCIES * Updated MSCloudLoginAssistant to version 1.0.96; * MISC - * Add support for ManagedIdentity to the SPo and OD resources. + * Add support for ManagedIdentity to the SPO and OD resources. * Fixed and issue with Export and ApplicationSecret where it wasn't properly converting to a PSCredential. * FIXES [#2447](https://github.com/microsoft/Microsoft365DSC/issues/2447)