Skip to content

Commit

Permalink
Merge pull request #4477 from NikCharlebois/Fixes-#4117
Browse files Browse the repository at this point in the history
Fixes #4117
  • Loading branch information
NikCharlebois authored Mar 21, 2024
2 parents 21cbec1 + fa3b1a9 commit 31cc6a0
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 40 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Get-TargetResource
(
[Parameter(Mandatory = $true)]
[System.String]
$Organization,
[ValidateSet('Yes')]
$IsSingleInstance,

[Parameter()]
[System.Boolean]
Expand Down Expand Up @@ -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' `
Expand Down Expand Up @@ -101,7 +102,7 @@ function Get-TargetResource
}

$result = @{
Organization = $Organization
IsSingleInstance = 'Yes'
MailTipsAllTipsEnabled = $OrgConfig.MailTipsAllTipsEnabled
MailTipsGroupMetricsEnabled = $OrgConfig.MailTipsGroupMetricsEnabled
MailTipsLargeAudienceThreshold = $OrgConfig.MailTipsLargeAudienceThreshold
Expand All @@ -117,7 +118,6 @@ function Get-TargetResource
TenantId = $TenantId
}

Write-Verbose -Message "Found configuration of the Mailtips for $($Organization)"
return $result
}
catch
Expand All @@ -140,7 +140,8 @@ function Set-TargetResource
(
[Parameter(Mandatory = $true)]
[System.String]
$Organization,
[ValidateSet('Yes')]
$IsSingleInstance,

[Parameter()]
[System.Boolean]
Expand Down Expand Up @@ -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
Expand All @@ -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
}
}
Expand All @@ -256,7 +257,8 @@ function Test-TargetResource
(
[Parameter(Mandatory = $true)]
[System.String]
$Organization,
[ValidateSet('Yes')]
$IsSingleInstance,

[Parameter()]
[System.Boolean]
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Configuration Example
{
EXOMailTips 'OrgWideMailTips'
{
Organization = $Domain
IsSingleInstance = 'Yes'
MailTipsAllTipsEnabled = $True
MailTipsGroupMetricsEnabled = $True
MailTipsLargeAudienceThreshold = 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Configuration Example
{
EXOMailTips 'OrgWideMailTips'
{
Organization = $Domain
IsSingleInstance = 'Yes'
MailTipsAllTipsEnabled = $True
MailTipsGroupMetricsEnabled = $False # Updated Property
MailTipsLargeAudienceThreshold = 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Configuration Example
{
EXOMailTips 'OrgWideMailTips'
{
Organization = $Domain
Ensure = "Absent"
Credential = $Credscredential
IsSingleInstance = 'Yes'
Ensure = "Absent"
Credential = $Credscredential
}
}
}
16 changes: 8 additions & 8 deletions Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOMailTips.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 31cc6a0

Please sign in to comment.