From 8940515351ee5d64a4ae30b19bb6e371cc99592f Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Wed, 1 Nov 2023 16:45:18 -0400 Subject: [PATCH] Fixes #3842 --- CHANGELOG.md | 6 ++++++ .../MSFT_O365OrgSettings/MSFT_O365OrgSettings.psm1 | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3697a33a6b..efec24833c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change log for Microsoft365DSC +# UNRELEASED + +* O365OrgSettings + * Force register the Office on the Web ServicePrincipal is it is not present. + FIXES [#3842](https://github.com/microsoft/Microsoft365DSC/issues/3842) + # 1.23.1101.1 * AADRoleEligibilityScheduleRequest diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_O365OrgSettings/MSFT_O365OrgSettings.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_O365OrgSettings/MSFT_O365OrgSettings.psm1 index e81751c228..7aae81cc87 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_O365OrgSettings/MSFT_O365OrgSettings.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_O365OrgSettings/MSFT_O365OrgSettings.psm1 @@ -196,7 +196,14 @@ function Get-TargetResource try { $OfficeOnlineId = 'c1f33bc0-bdb4-4248-ba9b-096807ddb43e' - $M365WebEnableUsersToOpenFilesFrom3PStorageValue = Get-MgServicePrincipal -Filter "appId eq '$OfficeOnlineId'" -Property 'AccountEnabled' + $M365WebEnableUsersToOpenFilesFrom3PStorageValue = Get-MgServicePrincipal -Filter "appId eq '$OfficeOnlineId'" -Property 'AccountEnabled' -ErrorAction SilentlyContinue + if ($null -eq $M365WebEnableUsersToOpenFilesFrom3PStorageValue) + { + Write-Verbose -Message "Registering the Office on the web Service Principal" + New-MgServicePrincipal -AppId 'c1f33bc0-bdb4-4248-ba9b-096807ddb43e' -ErrorAction Stop | Out-Null + $M365WebEnableUsersToOpenFilesFrom3PStorageValue = Get-MgServicePrincipal -Filter "appId eq '$OfficeOnlineId'" -Property 'AccountEnabled' -ErrorAction SilentlyContinue + } + if ($null -ne $M365WebEnableUsersToOpenFilesFrom3PStorageValue) { $results += @{