From fa3b1a9cffe0316b35735387502776980408b598 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Thu, 21 Mar 2024 12:36:38 -0400 Subject: [PATCH] Fixes #4117 --- CHANGELOG.md | 5 ++- .../MSFT_EXOMailTips/MSFT_EXOMailTips.psm1 | 41 ++++++++----------- .../MSFT_EXOMailTips.schema.mof | 2 +- .../Resources/EXOMailTips/1-Create.ps1 | 2 +- .../Resources/EXOMailTips/2-Update.ps1 | 2 +- .../Resources/EXOMailTips/3-Remove.ps1 | 6 +-- .../Microsoft365DSC.EXOMailTips.Tests.ps1 | 16 ++++---- 7 files changed, 34 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f036f9a359..8cddf0f04a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,12 +13,15 @@ * Fixed schema file * EXOGroupSettings * Fixed schema file +* EXOMailTips + * Replaced the Organization parameter with IsSingleInstance (BREAKING) + FIXES [#4117](https://github.com/microsoft/Microsoft365DSC/issues/4117) * EXOMessageClassification * Fixed schema file * EXOOMEConfiguration * Fixed schema file * EXOTransportRule - * Change data type of Priority from String to Int (breaking change) + * Change data type of Priority from String to Int (BREAKING) FIXES [[#4136](https://github.com/microsoft/Microsoft365DSC/issues/4136)] * IntuneAppConfigurationPolicy * Fix comparison in Test-TargetResource diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailTips/MSFT_EXOMailTips.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailTips/MSFT_EXOMailTips.psm1 index caaad88c9f..8cdca73ed4 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailTips/MSFT_EXOMailTips.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailTips/MSFT_EXOMailTips.psm1 @@ -6,7 +6,8 @@ function Get-TargetResource ( [Parameter(Mandatory = $true)] [System.String] - $Organization, + [ValidateSet('Yes')] + $IsSingleInstance, [Parameter()] [System.Boolean] @@ -62,7 +63,7 @@ function Get-TargetResource $ManagedIdentity ) - Write-Verbose -Message "Getting configuration of Mailtips for $Organization" + Write-Verbose -Message "Getting configuration of Mailtips" if ($Global:CurrentModeIsExport) { $ConnectionMode = New-M365DSCConnection -Workload 'ExchangeOnline' ` @@ -101,7 +102,7 @@ function Get-TargetResource } $result = @{ - Organization = $Organization + IsSingleInstance = 'Yes' MailTipsAllTipsEnabled = $OrgConfig.MailTipsAllTipsEnabled MailTipsGroupMetricsEnabled = $OrgConfig.MailTipsGroupMetricsEnabled MailTipsLargeAudienceThreshold = $OrgConfig.MailTipsLargeAudienceThreshold @@ -117,7 +118,6 @@ function Get-TargetResource TenantId = $TenantId } - Write-Verbose -Message "Found configuration of the Mailtips for $($Organization)" return $result } catch @@ -140,7 +140,8 @@ function Set-TargetResource ( [Parameter(Mandatory = $true)] [System.String] - $Organization, + [ValidateSet('Yes')] + $IsSingleInstance, [Parameter()] [System.Boolean] @@ -196,7 +197,7 @@ function Set-TargetResource $ManagedIdentity ) - Write-Verbose -Message "Setting configuration of Mailtips for $Organization" + Write-Verbose -Message "Setting configuration of Mailtips" #Ensure the proper dependencies are installed in the current environment. Confirm-M365DSCDependencies @@ -219,31 +220,31 @@ function Set-TargetResource if ($PSBoundParameters.ContainsKey('MailTipsAllTipsEnabled')) { - Write-Verbose -Message "Setting Mailtips for $($Organization) to $($MailTipsAllTipsEnabled)" + Write-Verbose -Message "Setting Mailtips to $($MailTipsAllTipsEnabled)" Set-OrganizationConfig -MailTipsAllTipsEnabled $MailTipsAllTipsEnabled } # CASE : MailTipsGroupMetricsEnabled is used if ($PSBoundParameters.ContainsKey('MailTipsGroupMetricsEnabled')) { - Write-Verbose -Message "Setting Mailtips for Group Metrics of $($Organization) to $($MailTipsGroupMetricsEnabled)" + Write-Verbose -Message "Setting Mailtips for Group Metrics to $($MailTipsGroupMetricsEnabled)" Set-OrganizationConfig -MailTipsGroupMetricsEnabled $MailTipsGroupMetricsEnabled } # CASE : MailTipsLargeAudienceThreshold is used if ($PSBoundParameters.ContainsKey('MailTipsLargeAudienceThreshold')) { - Write-Verbose -Message "Setting Mailtips for Large Audience of $($Organization) to $($MailTipsLargeAudienceThreshold)" + Write-Verbose -Message "Setting Mailtips for Large Audience to $($MailTipsLargeAudienceThreshold)" Set-OrganizationConfig -MailTipsLargeAudienceThreshold $MailTipsLargeAudienceThreshold } # CASE : MailTipsMailboxSourcedTipsEnabled is used if ($PSBoundParameters.ContainsKey('MailTipsMailboxSourcedTipsEnabled')) { - Write-Verbose -Message "Setting Mailtips for Mailbox Data (OOF/Mailbox Full) of $($Organization) to $($MailTipsMailboxSourcedTipsEnabled)" + Write-Verbose -Message "Setting Mailtips for Mailbox Data (OOF/Mailbox Full) to $($MailTipsMailboxSourcedTipsEnabled)" Set-OrganizationConfig -MailTipsMailboxSourcedTipsEnabled $MailTipsMailboxSourcedTipsEnabled } # CASE : MailTipsExternalRecipientsTipsEnabled is used if ($PSBoundParameters.ContainsKey('MailTipsExternalRecipientsTipsEnabled')) { - Write-Verbose -Message "Setting Mailtips for External Users of $($Organization) to $($MailTipsExternalRecipientsTipsEnabled)" + Write-Verbose -Message "Setting Mailtips for External Users to $($MailTipsExternalRecipientsTipsEnabled)" Set-OrganizationConfig -MailTipsExternalRecipientsTipsEnabled $MailTipsExternalRecipientsTipsEnabled } } @@ -256,7 +257,8 @@ function Test-TargetResource ( [Parameter(Mandatory = $true)] [System.String] - $Organization, + [ValidateSet('Yes')] + $IsSingleInstance, [Parameter()] [System.Boolean] @@ -324,7 +326,7 @@ function Test-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - Write-Verbose -Message "Testing configuration of Mailtips for $Organization" + Write-Verbose -Message "Testing configuration of Mailtips" $CurrentValues = Get-TargetResource @PSBoundParameters @@ -398,20 +400,9 @@ function Export-TargetResource try { - $OrganizationName = '' - if ($ConnectionMode -like 'ServicePrincipal*') - { - $OrganizationName = Get-M365DSCTenantDomain -ApplicationId $ApplicationId ` - -TenantId $TenantId ` - -CertificateThumbprint $CertificateThumbprint - } - else - { - $OrganizationName = $Credential.UserName.Split('@')[1] - } $Params = @{ Credential = $Credential - Organization = $OrganizationName + IsSingleInstance = 'Yes' ApplicationId = $ApplicationId TenantId = $TenantId CertificateThumbprint = $CertificateThumbprint diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailTips/MSFT_EXOMailTips.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailTips/MSFT_EXOMailTips.schema.mof index 070d9c825d..84b683c9f2 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailTips/MSFT_EXOMailTips.schema.mof +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailTips/MSFT_EXOMailTips.schema.mof @@ -2,7 +2,7 @@ [ClassVersion("1.0.0.0"), FriendlyName("EXOMailTips")] class MSFT_EXOMailTips : OMI_BaseResource { - [Key, Description("Specify the name of your organization.")] String Organization; + [Key, Description("Only valid value is 'Yes'."), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance; [Write, Description("Specifies whether MailTips are enabled.")] Boolean MailTipsAllTipsEnabled; [Write, Description("Specifies whether MailTips that rely on group metrics data are enabled.")] Boolean MailTipsGroupMetricsEnabled; [Write, Description("Specifies what a large audience is.")] UInt32 MailTipsLargeAudienceThreshold; diff --git a/Modules/Microsoft365DSC/Examples/Resources/EXOMailTips/1-Create.ps1 b/Modules/Microsoft365DSC/Examples/Resources/EXOMailTips/1-Create.ps1 index 3c71726bab..b58921fed5 100644 --- a/Modules/Microsoft365DSC/Examples/Resources/EXOMailTips/1-Create.ps1 +++ b/Modules/Microsoft365DSC/Examples/Resources/EXOMailTips/1-Create.ps1 @@ -17,7 +17,7 @@ Configuration Example { EXOMailTips 'OrgWideMailTips' { - Organization = $Domain + IsSingleInstance = 'Yes' MailTipsAllTipsEnabled = $True MailTipsGroupMetricsEnabled = $True MailTipsLargeAudienceThreshold = 100 diff --git a/Modules/Microsoft365DSC/Examples/Resources/EXOMailTips/2-Update.ps1 b/Modules/Microsoft365DSC/Examples/Resources/EXOMailTips/2-Update.ps1 index 172deb2c04..95cafdbc6c 100644 --- a/Modules/Microsoft365DSC/Examples/Resources/EXOMailTips/2-Update.ps1 +++ b/Modules/Microsoft365DSC/Examples/Resources/EXOMailTips/2-Update.ps1 @@ -17,7 +17,7 @@ Configuration Example { EXOMailTips 'OrgWideMailTips' { - Organization = $Domain + IsSingleInstance = 'Yes' MailTipsAllTipsEnabled = $True MailTipsGroupMetricsEnabled = $False # Updated Property MailTipsLargeAudienceThreshold = 100 diff --git a/Modules/Microsoft365DSC/Examples/Resources/EXOMailTips/3-Remove.ps1 b/Modules/Microsoft365DSC/Examples/Resources/EXOMailTips/3-Remove.ps1 index d4e681aa7d..3a010d19d9 100644 --- a/Modules/Microsoft365DSC/Examples/Resources/EXOMailTips/3-Remove.ps1 +++ b/Modules/Microsoft365DSC/Examples/Resources/EXOMailTips/3-Remove.ps1 @@ -17,9 +17,9 @@ Configuration Example { EXOMailTips 'OrgWideMailTips' { - Organization = $Domain - Ensure = "Absent" - Credential = $Credscredential + IsSingleInstance = 'Yes' + Ensure = "Absent" + Credential = $Credscredential } } } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOMailTips.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOMailTips.Tests.ps1 index f7a8f5cb63..e266eba092 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOMailTips.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOMailTips.Tests.ps1 @@ -40,7 +40,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Context -Name 'MailTips are Disabled and should be Enabled' -Fixture { BeforeAll { $testParams = @{ - Organization = 'contoso.onmicrosoft.com' + IsSingleInstance = 'Yes' MailTipsAllTipsEnabled = $True Ensure = 'Present' Credential = $Credential @@ -73,7 +73,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Context -Name 'MailTipsGroupMetricsEnabled are Disabled and should be Enabled' -Fixture { BeforeAll { $testParams = @{ - Organization = 'contoso.onmicrosoft.com' + IsSingleInstance = 'Yes' MailTipsGroupMetricsEnabled = $True Ensure = 'Present' Credential = $Credential @@ -106,7 +106,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Context -Name 'MailTipsLargeAudienceThreshold are 25 and should be 50' -Fixture { BeforeAll { $testParams = @{ - Organization = 'contoso.onmicrosoft.com' + IsSingleInstance = 'Yes' MailTipsLargeAudienceThreshold = 50 Ensure = 'Present' Credential = $Credential @@ -139,7 +139,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Context -Name 'MailTipsMailboxSourcedTipsEnabled are Disabled and should be Enabled' -Fixture { BeforeAll { $testParams = @{ - Organization = 'contoso.onmicrosoft.com' + IsSingleInstance = 'Yes' MailTipsMailboxSourcedTipsEnabled = $True Ensure = 'Present' Credential = $Credential @@ -168,7 +168,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Context -Name 'MailTipsExternalRecipientsTipsEnabled are Disabled and should be Enabled' -Fixture { BeforeAll { $testParams = @{ - Organization = 'contoso.onmicrosoft.com' + IsSingleInstance = 'Yes' MailTipsExternalRecipientsTipsEnabled = $True Ensure = 'Present' Credential = $Credential @@ -201,7 +201,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Context -Name 'MailTips are Enabled and should be Enabled' -Fixture { BeforeAll { $testParams = @{ - Organization = 'contoso.onmicrosoft.com' + IsSingleInstance = 'Yes' MailTipsAllTipsEnabled = $True MailTipsLargeAudienceThreshold = 10 MailTipsMailboxSourcedTipsEnabled = $True @@ -234,7 +234,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Context -Name 'Organization Configuration is null' -Fixture { BeforeAll { $testParams = @{ - Organization = 'contoso.onmicrosoft.com' + IsSingleInstance = 'Yes' MailTipsAllTipsEnabled = $True Ensure = 'Present' Credential = $Credential @@ -260,7 +260,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Mock -CommandName Get-OrganizationConfig -MockWith { return @{ - Organization = 'contoso.onmicrosoft.com' + IsSingleInstance = 'Yes' MailTipsAllTipsEnabled = $True MailTipsGroupMetricsEnabled = $True MailTipsLargeAudienceThreshold = $True