From 5be4bd755e0a901dc2f5bd18c5af56145186e3a6 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Tue, 4 Jul 2023 11:24:35 -0400 Subject: [PATCH] Fixes #3314 --- CHANGELOG.md | 6 +++ .../MSFT_EXOMailboxPlan.psm1 | 51 ++++++++++--------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 246fe21f24..e25e154a8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change log for Microsoft365DSC +# UNRELEASED + +* EXOMailboxPlan + * Support comparing instances without the GUID in the name. + FIXES [#3314](https://github.com/microsoft/Microsoft365DSC/issues/3314) + # 1.23.628.1 * AADAdministrativeUnit diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailboxPlan/MSFT_EXOMailboxPlan.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailboxPlan/MSFT_EXOMailboxPlan.psm1 index ae15cfe1fa..aae6a4a598 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailboxPlan/MSFT_EXOMailboxPlan.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailboxPlan/MSFT_EXOMailboxPlan.psm1 @@ -111,33 +111,36 @@ function Get-TargetResource if ($null -eq $MailboxPlan) { Write-Verbose -Message "MailboxPlan $($Identity) does not exist." - return $nullResult - } - else - { - $result = @{ - Identity = $Identity - IssueWarningQuota = $MailboxPlan.IssueWarningQuota - MaxReceiveSize = $MailboxPlan.MaxReceiveSize - MaxSendSize = $MailboxPlan.MaxSendSize - ProhibitSendQuota = $MailboxPlan.ProhibitSendQuota - ProhibitSendReceiveQuota = $MailboxPlan.ProhibitSendReceiveQuota - RetainDeletedItemsFor = $MailboxPlan.RetainDeletedItemsFor - RetentionPolicy = $MailboxPlan.RetentionPolicy - RoleAssignmentPolicy = $MailboxPlan.RoleAssignmentPolicy - Credential = $Credential - ApplicationId = $ApplicationId - CertificateThumbprint = $CertificateThumbprint - CertificatePath = $CertificatePath - CertificatePassword = $CertificatePassword - Managedidentity = $ManagedIdentity.IsPresent - TenantId = $TenantId + + $MailboxPlan = Get-MailboxPlan -Filter "Name like '$($Identity.Split('-')[0])*'" + if ($null -eq $MailboxPlan) + { + return $nullResult } + } - Write-Verbose -Message "Found MailboxPlan $($Identity)" - Write-Verbose -Message "Get-TargetResource Result: `n $(Convert-M365DscHashtableToString -Hashtable $result)" - return $result + $result = @{ + Identity = $Identity + IssueWarningQuota = $MailboxPlan.IssueWarningQuota + MaxReceiveSize = $MailboxPlan.MaxReceiveSize + MaxSendSize = $MailboxPlan.MaxSendSize + ProhibitSendQuota = $MailboxPlan.ProhibitSendQuota + ProhibitSendReceiveQuota = $MailboxPlan.ProhibitSendReceiveQuota + RetainDeletedItemsFor = $MailboxPlan.RetainDeletedItemsFor + RetentionPolicy = $MailboxPlan.RetentionPolicy + RoleAssignmentPolicy = $MailboxPlan.RoleAssignmentPolicy + Credential = $Credential + ApplicationId = $ApplicationId + CertificateThumbprint = $CertificateThumbprint + CertificatePath = $CertificatePath + CertificatePassword = $CertificatePassword + Managedidentity = $ManagedIdentity.IsPresent + TenantId = $TenantId } + + Write-Verbose -Message "Found MailboxPlan $($Identity)" + Write-Verbose -Message "Get-TargetResource Result: `n $(Convert-M365DscHashtableToString -Hashtable $result)" + return $result } catch {