diff --git a/CHANGELOG.md b/CHANGELOG.md index e935868ca2..958e68e7a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ # UNRELEASED +* AADEntitlementManagementConnectedOrganization + * Fixed [[#3738](https://github.com/microsoft/Microsoft365DSC/issues/3738)] * EXOCalendarProcessing * Initial release. * DEPENDENCIES diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADEntitlementManagementConnectedOrganization/MSFT_AADEntitlementManagementConnectedOrganization.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADEntitlementManagementConnectedOrganization/MSFT_AADEntitlementManagementConnectedOrganization.psm1 index 51cd891750..637425e5d9 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADEntitlementManagementConnectedOrganization/MSFT_AADEntitlementManagementConnectedOrganization.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADEntitlementManagementConnectedOrganization/MSFT_AADEntitlementManagementConnectedOrganization.psm1 @@ -313,8 +313,10 @@ function Set-TargetResource $CreateParameters.$key = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $CreateParameters.$key } } - - $newConnectedOrganization = New-MgBetaEntitlementManagementConnectedOrganization -BodyParameter $CreateParameters + $TenantId = $CreateParameters.IdentitySources.ExternalTenantId + $url = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/tenantRelationships/microsoft.graph.findTenantInformationByTenantId(tenantId='$tenantid')" + $DomainName = (Invoke-MgGraphRequest -Method 'GET' -Uri $url).defaultDomainName + $newConnectedOrganization = New-MgBetaEntitlementManagementConnectedOrganization -Description $CreateParameters.Description -DisplayName $CreateParameters.DisplayName -State $CreateParameters.State -DomainName $DomainName foreach ($sponsor in $ExternalSponsors) { diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADEntitlementManagementConnectedOrganization.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADEntitlementManagementConnectedOrganization.Tests.ps1 index 9deb3692a5..7ead2f0a36 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADEntitlementManagementConnectedOrganization.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADEntitlementManagementConnectedOrganization.Tests.ps1 @@ -51,6 +51,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Mock -CommandName New-M365DSCConnection -MockWith { return 'Credentials' } + Mock -CommandName Invoke-MgGraphRequest -MockWith { + return @{} + } # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith {