From d29166f68fd9cb0a9f41173e68354682a1905b4a Mon Sep 17 00:00:00 2001 From: Nik Charlebois <nicharl@microsoft.com> Date: Thu, 11 Jul 2024 11:32:38 -0400 Subject: [PATCH 1/3] Release 1.24.710.3 --- CHANGELOG.md | 5 + Modules/Microsoft365DSC/Microsoft365DSC.psd1 | 6 +- .../Microsoft365DSC/Modules/M365DSCUtil.psm1 | 157 ++++++++++++++---- 3 files changed, 135 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a91791ba43..37f9f8c9ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change log for Microsoft365DSC +# 1.24.710.3 + +* MISC + * Fixesd issue with App Secret Authentication flow. + # 1.24.710.2 * Telemetry diff --git a/Modules/Microsoft365DSC/Microsoft365DSC.psd1 b/Modules/Microsoft365DSC/Microsoft365DSC.psd1 index b562ab2eab..f045b33f23 100644 --- a/Modules/Microsoft365DSC/Microsoft365DSC.psd1 +++ b/Modules/Microsoft365DSC/Microsoft365DSC.psd1 @@ -11,7 +11,7 @@ # RootModule = '' # Version number of this module. - ModuleVersion = '1.24.710.2' + ModuleVersion = '1.24.710.3' # Supported PSEditions # CompatiblePSEditions = @() @@ -161,7 +161,9 @@ * DEPENDENCIES * Updated DSCParser to version 2.0.0.7. * Updated Microsoft.Graph to version 2.20.0 - * Updated Microsoft.PowerApps.Administration.PowerShell to version 2.0.191' + * Updated Microsoft.PowerApps.Administration.PowerShell to version 2.0.191 +* MISC + * Fixesd issue with App Secret Authentication flow.' # Flag to indicate whether the module requires explicit user acceptance for install/update # RequireLicenseAcceptance = $false diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index b0c64e487f..03b4cbbf70 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -1804,7 +1804,10 @@ function New-M365DSCConnection if ($InboundParameters.ApplicationSecret) { $InboundParameters.ApplicationSecret = $InboundParameters.ApplicationSecret.GetNetworkCredential().Password - $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationSecret', $InboundParameters.ApplicationSecret) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationSecret')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationSecret', $InboundParameters.ApplicationSecret) + } } # Case both authentication methods are attempted @@ -1845,7 +1848,10 @@ function New-M365DSCConnection Write-Verbose -Message 'Credential was specified. Connecting via User Principal' if ([System.String]::IsNullOrEmpty($Url)) { - $Global:M365DSCTelemetryConnectionToGraphParams.Add('Credential', $InboundParameters.Credential) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('Credential')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('Credential', $InboundParameters.Credential) + } Connect-M365Tenant -Workload $Workload ` -Credential $InboundParameters.Credential ` -SkipModuleReload $Global:CurrentModeIsExport @@ -1859,7 +1865,11 @@ function New-M365DSCConnection { $tenantId = $InboundParameters.Credential.Username.Split('@')[1] $data.Add('Tenant', $tenantId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $tenantId) + + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationSecret')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicatonSecret', $tenantId) + } } } catch @@ -1875,7 +1885,10 @@ function New-M365DSCConnection if ($InboundParameters.ContainsKey('Credential') -and $null -ne $InboundParameters.Credential) { - $Global:M365DSCTelemetryConnectionToGraphParams.Add('Credential', $InboundParameters.Credential) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('Credential')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('Credential', $InboundParameters.Credential) + } Connect-M365Tenant -Workload $Workload ` -Credential $InboundParameters.Credential ` -Url $Url ` @@ -1889,7 +1902,10 @@ function New-M365DSCConnection { $tenantId = $InboundParameters.Credential.Username.Split('@')[1] $data.Add('Tenant', $tenantId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $tenantId) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('TenantId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $tenantId) + } } } catch @@ -1911,8 +1927,14 @@ function New-M365DSCConnection { if ([System.String]::IsNullOrEmpty($Url)) { - $Global:M365DSCTelemetryConnectionToGraphParams.Add('Credential', $InboundParameters.Credential) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $InboundParameters.ApplicationId) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('Credential')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('Credential', $InboundParameters.Credential) + } + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $InboundParameters.ApplicationId) + } Connect-M365Tenant -Workload $Workload ` -ApplicationId $InboundParameters.ApplicationId ` -Credential $InboundParameters.Credential ` @@ -1927,7 +1949,10 @@ function New-M365DSCConnection { $tenantId = $InboundParameters.Credential.Username.Split('@')[1] $data.Add('Tenant', $tenantId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $tenantId) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('TenantId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $tenantId) + } } } catch @@ -1942,8 +1967,14 @@ function New-M365DSCConnection } else { - $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $InboundParameters.ApplicationId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('Credential', $InboundParameters.Credential) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationSecret')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationSecret', $InboundParameters.ApplicationId) + } + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('Credential')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('Credential', $InboundParameters.Credential) + } Connect-M365Tenant -Workload $Workload ` -ApplicationId $InboundParameters.ApplicationId ` -Credential $InboundParameters.Credential ` @@ -1959,7 +1990,10 @@ function New-M365DSCConnection { $tenantId = $InboundParameters.Credential.Username.Split('@')[1] $data.Add('Tenant', $tenantId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $tenantId) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $tenantId) + } } } catch @@ -1984,10 +2018,22 @@ function New-M365DSCConnection { Write-Verbose -Message 'ApplicationId, TenantId, CertificatePath & CertificatePassword were specified. Connecting via Service Principal' - $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $InboundParameters.ApplicationId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('CertificatePassword', $InboundParameters.CertificatePassword.Password) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('CertificatePath', $InboundParameters.CertificatePath) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $InboundParameters.ApplicationId) + } + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('TenantId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) + } + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('CertificatePassword')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('CertificatePassword', $InboundParameters.CertificatePassword.Password) + } + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('CertificatePath')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('CertificatePath', $InboundParameters.CertificatePath) + } Connect-M365Tenant -Workload $Workload ` -ApplicationId $InboundParameters.ApplicationId ` -TenantId $InboundParameters.TenantId ` @@ -2001,7 +2047,10 @@ function New-M365DSCConnection if (-not $data.ContainsKey('Tenant')) { $data.Add('Tenant', $InboundParameters.TenantId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('TenantId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) + } } Add-M365DSCTelemetryEvent -Data $data -Type 'Connection' $Script:M365ConnectedToWorkloads += "$Workload-ServicePrincipalWithPath" @@ -2054,9 +2103,18 @@ function New-M365DSCConnection { Write-Verbose -Message 'ApplicationId, TenantId, ApplicationSecret were specified. Connecting via Service Principal' - $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $InboundParameters.ApplicationId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationSecret', $InboundParameters.ApplicationSecret) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $InboundParameters.ApplicationId) + } + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('TenantId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) + } + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationSecret')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationSecret', $InboundParameters.ApplicationSecret) + } Connect-M365Tenant -Workload $Workload ` -ApplicationId $InboundParameters.ApplicationId ` -TenantId $InboundParameters.TenantId ` @@ -2077,9 +2135,18 @@ function New-M365DSCConnection } else { - $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $InboundParameters.ApplicationId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationSecret', $InboundParameters.ApplicationSecret) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $InboundParameters.ApplicationId) + } + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('TenantId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) + } + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationSecret')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationSecret', $InboundParameters.ApplicationSecret) + } Connect-M365Tenant -Workload $Workload ` -ApplicationId $InboundParameters.ApplicationId ` -TenantId $InboundParameters.TenantId ` @@ -2104,9 +2171,18 @@ function New-M365DSCConnection { Write-Verbose -Message 'ApplicationId, TenantId, CertificateThumbprint were specified. Connecting via Service Principal' - $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $InboundParameters.ApplicationId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('CertificateThumbprint', $InboundParameters.CertificateThumbprint) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $InboundParameters.ApplicationId) + } + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('TenantId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) + } + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('CertificateThumbprint')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('CertificateThumbprint', $InboundParameters.CertificateThumbprint) + } Connect-M365Tenant -Workload $Workload ` -ApplicationId $InboundParameters.ApplicationId ` -TenantId $InboundParameters.TenantId ` @@ -2129,8 +2205,14 @@ function New-M365DSCConnection elseif ($null -ne $InboundParameters.Credential -and ` -not [System.String]::IsNullOrEmpty($InboundParameters.TenantId)) { - $Global:M365DSCTelemetryConnectionToGraphParams.Add('Credential', $InboundParameters.Credential) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('Credential')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('Credential', $InboundParameters.Credential) + } + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('CertificateThumbprint')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) + } Connect-M365Tenant -Workload $Workload ` -TenantId $InboundParameters.TenantId ` -Credential $InboundParameters.Credential ` @@ -2154,8 +2236,14 @@ function New-M365DSCConnection { Write-Verbose -Message 'Connecting via managed identity' - $Global:M365DSCTelemetryConnectionToGraphParams.Add('Identity', $true) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('Identity')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('Identity', $true) + } + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('TenantId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) + } Connect-M365Tenant -Workload $Workload ` -Identity ` -TenantId $InboundParameters.TenantId ` @@ -2179,8 +2267,15 @@ function New-M365DSCConnection { Write-Verbose -Message 'Connecting via Access Tokens' - $Global:M365DSCTelemetryConnectionToGraphParams.Add('AccessTokens', $InboundParameters.AccessTokens) - $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('AccessTokens')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('AccessTokens', $InboundParameters.AccessTokens) + } + + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('TenantId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) + } Connect-M365Tenant -Workload $Workload ` -AccessTokens $InboundParameters.AccessTokens ` -TenantId $InboundParameters.TenantId ` From df293e85dd97de8e28172e7619a02c0fbbd20d97 Mon Sep 17 00:00:00 2001 From: Nik Charlebois <nicharl@microsoft.com> Date: Thu, 11 Jul 2024 11:33:54 -0400 Subject: [PATCH 2/3] Fixes Typo --- CHANGELOG.md | 2 +- Modules/Microsoft365DSC/Microsoft365DSC.psd1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37f9f8c9ef..5f62077cf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ # 1.24.710.3 * MISC - * Fixesd issue with App Secret Authentication flow. + * Fixes issue with App Secret Authentication flow. # 1.24.710.2 diff --git a/Modules/Microsoft365DSC/Microsoft365DSC.psd1 b/Modules/Microsoft365DSC/Microsoft365DSC.psd1 index f045b33f23..56af643474 100644 --- a/Modules/Microsoft365DSC/Microsoft365DSC.psd1 +++ b/Modules/Microsoft365DSC/Microsoft365DSC.psd1 @@ -163,7 +163,7 @@ * Updated Microsoft.Graph to version 2.20.0 * Updated Microsoft.PowerApps.Administration.PowerShell to version 2.0.191 * MISC - * Fixesd issue with App Secret Authentication flow.' + * Fixes issue with App Secret Authentication flow.' # Flag to indicate whether the module requires explicit user acceptance for install/update # RequireLicenseAcceptance = $false From 7122108a1e67b73a34ed83d1a61c5af22fc07703 Mon Sep 17 00:00:00 2001 From: Nik Charlebois <nicharl@microsoft.com> Date: Thu, 11 Jul 2024 11:36:27 -0400 Subject: [PATCH 3/3] Fixes --- Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index 03b4cbbf70..882674e3a4 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -1866,9 +1866,9 @@ function New-M365DSCConnection $tenantId = $InboundParameters.Credential.Username.Split('@')[1] $data.Add('Tenant', $tenantId) - if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationSecret')) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('TenantId')) { - $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicatonSecret', $tenantId) + $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $tenantId) } } } @@ -1967,9 +1967,9 @@ function New-M365DSCConnection } else { - if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationSecret')) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('ApplicationId')) { - $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationSecret', $InboundParameters.ApplicationId) + $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $InboundParameters.ApplicationId) } if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('Credential')) { @@ -2209,7 +2209,7 @@ function New-M365DSCConnection { $Global:M365DSCTelemetryConnectionToGraphParams.Add('Credential', $InboundParameters.Credential) } - if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('CertificateThumbprint')) + if (-not $Global:M365DSCTelemetryConnectionToGraphParams.ContainsKey('TenantId')) { $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $InboundParameters.TenantId) }