From 1b95a628ac9ba688b5019cf6afb0d507c2660beb Mon Sep 17 00:00:00 2001 From: Fabien Tschanz Date: Mon, 16 Dec 2024 22:47:05 +0100 Subject: [PATCH] Reset only necessary authentication context --- CHANGELOG.md | 1 + .../MSFT_EXOManagementRoleAssignment.psm1 | 2 +- .../DSCResources/MSFT_O365OrgSettings/MSFT_O365OrgSettings.psm1 | 2 +- Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae5a5ea19e..f4dc1e40bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * Fixed the Fabric web request to use basic parsing. * Fixed an issue where the export does not convert tenant name into generic $OrganizationName variable correctly. + * Reset only necessary authentication context. * M365DSCUtil * Update `Get-M365DSCWorkloadsListFromResourceNames` function for more input types. FIXES [#5525](https://github.com/microsoft/Microsoft365DSC/issues/5525) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOManagementRoleAssignment/MSFT_EXOManagementRoleAssignment.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOManagementRoleAssignment/MSFT_EXOManagementRoleAssignment.psm1 index 8563e58c42..079b515252 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOManagementRoleAssignment/MSFT_EXOManagementRoleAssignment.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOManagementRoleAssignment/MSFT_EXOManagementRoleAssignment.psm1 @@ -387,7 +387,7 @@ function Set-TargetResource Write-Verbose -Message 'Waiting for 20 seconds for new permissions to be effective.' Start-Sleep 20 Write-Verbose -Message 'Disconnecting from Exchange Online' - Reset-MSCloudLoginConnectionProfileContext + Reset-MSCloudLoginConnectionProfileContext -Workload ExchangeOnline } } diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_O365OrgSettings/MSFT_O365OrgSettings.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_O365OrgSettings/MSFT_O365OrgSettings.psm1 index aa2d5c8056..aa30e5e426 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_O365OrgSettings/MSFT_O365OrgSettings.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_O365OrgSettings/MSFT_O365OrgSettings.psm1 @@ -165,7 +165,7 @@ function Get-TargetResource if ((Get-MSCloudLoginConnectionProfile -Workload SecurityComplianceCenter).Connected -and ` (Get-MSCloudLoginConnectionProfile -Workload ExchangeOnline).Connected) { - Reset-MSCloudLoginConnectionProfileContext + Reset-MSCloudLoginConnectionProfileContext -Workload ExchangeOnline } $ConnectionMode = New-M365DSCConnection -Workload 'ExchangeOnline' ` -InboundParameters $PSBoundParameters diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index 7681c9f081..3846ec98ce 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -1437,7 +1437,7 @@ function Export-M365DSCConfiguration try { Disconnect-MgGraph -ErrorAction Stop | Out-Null - Reset-MSCloudLoginConnectionProfileContext + Reset-MSCloudLoginConnectionProfileContext -Workload 'MicrosoftGraph' } catch {