diff --git a/CHANGELOG.md b/CHANGELOG.md index a91791ba43..5f62077cf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change log for Microsoft365DSC +# 1.24.710.3 + +* MISC + * Fixes 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..56af643474 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 + * Fixes 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..882674e3a4 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('TenantId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('TenantId', $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('ApplicationId')) + { + $Global:M365DSCTelemetryConnectionToGraphParams.Add('ApplicationId', $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('TenantId')) + { + $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 `