Skip to content

Commit

Permalink
fix for microsoft#2942
Browse files Browse the repository at this point in the history
original PR failed when I tried to resolve conflicts, merged nothing - this contains the changes present in that PR
  • Loading branch information
menswearUK committed Mar 9, 2023
1 parent 5f026f3 commit ddd9aab
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
actually exist.
* Added application credential support to Assert-M365DSCBlueprint
FIXES [#1792](https://github.com/microsoft/Microsoft365DSC/pull/1792)
* Added checks in New-M365DSCConnection to ensure beta MSGraph profile is correctly set when requested
FIXES [#2942](https://github.com/microsoft/Microsoft365DSC/issues/2942)
* Updated/added various examples
* DEPENDENCIES
* Updated MicrosoftTeams to version 5.0.0
Expand Down
72 changes: 72 additions & 0 deletions Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,13 @@ function New-M365DSCConnection
-Credential $InboundParameters.Credential `
-SkipModuleReload $Global:CurrentModeIsExport `
-ProfileName $ProfileName

#2942 - check correct profile applied
if (($ProfileName -ne $global:MSCloudLoginConnectionProfile.MicrosoftGraph.ProfileName) -and ($Workload -eq 'MicrosoftGraph') )
{
Select-MgProfile -Name $ProfileName
}

$data.Add('ConnectionType', 'Credential')

try
Expand All @@ -1617,6 +1624,13 @@ function New-M365DSCConnection
-Url $Url `
-SkipModuleReload $Global:CurrentModeIsExport `
-ProfileName $ProfileName

#2942 - check correct profile applied
if (($ProfileName -ne $global:MSCloudLoginConnectionProfile.MicrosoftGraph.ProfileName) -and ($Workload -eq 'MicrosoftGraph') )
{
Select-MgProfile -Name $ProfileName
}

$data.Add('ConnectionType', 'Credential')

try
Expand Down Expand Up @@ -1646,6 +1660,13 @@ function New-M365DSCConnection
-Credential $InboundParameters.Credential `
-SkipModuleReload $Global:CurrentModeIsExport `
-ProfileName $ProfileName

#2942 - check correct profile applied
if (($ProfileName -ne $global:MSCloudLoginConnectionProfile.MicrosoftGraph.ProfileName) -and ($Workload -eq 'MicrosoftGraph') )
{
Select-MgProfile -Name $ProfileName
}

$data.Add('ConnectionType', 'CredentialsWithApplicationId')

try
Expand All @@ -1669,6 +1690,13 @@ function New-M365DSCConnection
-Url $Url `
-SkipModuleReload $Global:CurrentModeIsExport `
-ProfileName $ProfileName

#2942 - check correct profile applied
if (($ProfileName -ne $global:MSCloudLoginConnectionProfile.MicrosoftGraph.ProfileName) -and ($Workload -eq 'MicrosoftGraph') )
{
Select-MgProfile -Name $ProfileName
}

$data.Add('ConnectionType', 'CredentialsWithApplicationId')

try
Expand Down Expand Up @@ -1703,6 +1731,12 @@ function New-M365DSCConnection
-SkipModuleReload $Global:CurrentModeIsExport `
-ProfileName $ProfileName

#2942 - check correct profile applied
if (($ProfileName -ne $global:MSCloudLoginConnectionProfile.MicrosoftGraph.ProfileName) -and ($Workload -eq 'MicrosoftGraph') )
{
Select-MgProfile -Name $ProfileName
}

$data.Add('ConnectionType', 'ServicePrincipalWithPath')
$data.Add('Tenant', $InboundParameters.TenantId)
Add-M365DSCTelemetryEvent -Data $data -Type 'Connection'
Expand Down Expand Up @@ -1762,6 +1796,13 @@ function New-M365DSCConnection
-SkipModuleReload $Global:CurrentModeIsExport `
-ProfileName $ProfileName
}

#2942 - check correct profile applied
if (($ProfileName -ne $global:MSCloudLoginConnectionProfile.MicrosoftGraph.ProfileName) -and ($Workload -eq 'MicrosoftGraph') )
{
Select-MgProfile-Name $ProfileName
}

$data.Add('ConnectionType', 'Credential')
try
{
Expand All @@ -1788,6 +1829,13 @@ function New-M365DSCConnection
-Url $Url `
-SkipModuleReload $Global:CurrentModeIsExport `
-ProfileName $ProfileName

#2942 - check correct profile applied
if (($ProfileName -ne $global:MSCloudLoginConnectionProfile.MicrosoftGraph.ProfileName) -and ($Workload -eq 'MicrosoftGraph') )
{
Select-MgProfile -Name $ProfileName
}

}
$data.Add('ConnectionType', 'ServicePrincipalWithPath')
$data.Add('Tenant', $InboundParameters.TenantId)
Expand All @@ -1811,6 +1859,12 @@ function New-M365DSCConnection
-SkipModuleReload $Global:CurrentModeIsExport `
-ProfileName $ProfileName

#2942 - check correct profile applied
if (($ProfileName -ne $global:MSCloudLoginConnectionProfile.MicrosoftGraph.ProfileName) -and ($Workload -eq 'MicrosoftGraph') )
{
Select-MgProfile -Name $ProfileName
}

$data.Add('ConnectionType', 'ServicePrincipalWithSecret')
$data.Add('Tenant', $InboundParameters.TenantId)
Add-M365DSCTelemetryEvent -Data $data -Type 'Connection'
Expand All @@ -1826,6 +1880,12 @@ function New-M365DSCConnection
-SkipModuleReload $Global:CurrentModeIsExport `
-ProfileName $ProfileName

#2942 - check correct profile applied
if (($ProfileName -ne $global:MSCloudLoginConnectionProfile.MicrosoftGraph.ProfileName) -and ($Workload -eq 'MicrosoftGraph') )
{
Select-MgProfile -Name $ProfileName
}

$data.Add('ConnectionType', 'ServicePrincipalWithSecret')
$data.Add('Tenant', $InboundParameters.TenantId)
Add-M365DSCTelemetryEvent -Data $data -Type 'Connection'
Expand All @@ -1843,6 +1903,12 @@ function New-M365DSCConnection
-ProfileName $ProfileName `
-Url $Url

#2942 - check correct profile applied
if (($ProfileName -ne $global:MSCloudLoginConnectionProfile.MicrosoftGraph.ProfileName) -and ($Workload -eq 'MicrosoftGraph') )
{
Select-MgProfile -Name $ProfileName
}

$data.Add('ConnectionType', 'ServicePrincipalWithThumbprint')
$data.Add('Tenant', $InboundParameters.TenantId)
Add-M365DSCTelemetryEvent -Data $data -Type 'Connection'
Expand All @@ -1859,6 +1925,12 @@ function New-M365DSCConnection
-SkipModuleReload $Global:CurrentModeIsExport `
-ProfileName $ProfileName

#2942 - check correct profile applied
if (($ProfileName -ne $global:MSCloudLoginConnectionProfile.MicrosoftGraph.ProfileName) -and ($Workload -eq 'MicrosoftGraph') )
{
Select-MgProfile -Name $ProfileName
}

$data.Add('ConnectionType', 'ManagedIdentity')
$data.Add('Tenant', $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.TenantId)
Add-M365DSCTelemetryEvent -Data $data -Type 'Connection'
Expand Down

0 comments on commit ddd9aab

Please sign in to comment.