Skip to content

Commit

Permalink
Merge pull request #4863 from microsoft/Dev
Browse files Browse the repository at this point in the history
Release 1.24.710.3
  • Loading branch information
NikCharlebois authored Jul 11, 2024
2 parents 0ccb693 + fa813e6 commit f1d6a92
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 33 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions Modules/Microsoft365DSC/Microsoft365DSC.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# RootModule = ''

# Version number of this module.
ModuleVersion = '1.24.710.2'
ModuleVersion = '1.24.710.3'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -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
Expand Down
157 changes: 126 additions & 31 deletions Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 `
Expand All @@ -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
Expand All @@ -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 `
Expand All @@ -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
Expand All @@ -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 `
Expand All @@ -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
Expand All @@ -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 `
Expand All @@ -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"
Expand Down Expand Up @@ -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 `
Expand All @@ -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 `
Expand All @@ -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 `
Expand All @@ -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 `
Expand All @@ -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 `
Expand All @@ -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 `
Expand Down

0 comments on commit f1d6a92

Please sign in to comment.