Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NikCharlebois committed Nov 15, 2023
1 parent 281640f commit 11453ab
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change log for Microsoft365DSC

# UNRELEASED

* EXOCASMailboxPlan
* Fixes an issue where we are not able to set the settings of a CAS
Mailbox Plan by specifying the Identity without the GUID in the name.
FIXES [#3900](https://github.com/microsoft/Microsoft365DSC/issues/3900)

# 1.23.1108.3

* AADRoleEligibilityScheduleRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,33 +91,36 @@ function Get-TargetResource
try
{
$CASMailboxPlan = Get-CASMailboxPlan -Identity $Identity -ErrorAction Stop

if ($null -eq $CASMailboxPlan)
{
Write-Verbose -Message "CASMailboxPlan $($Identity) does not exist."
return $nullResult
}
else
if ($null -eq $MailboxPlan)
{
$result = @{
Identity = $Identity
ActiveSyncEnabled = $CASMailboxPlan.ActiveSyncEnabled
ImapEnabled = $CASMailboxPlan.ImapEnabled
OwaMailboxPolicy = $CASMailboxPlan.OwaMailboxPolicy
PopEnabled = $CASMailboxPlan.PopEnabled
Credential = $Credential
ApplicationId = $ApplicationId
CertificateThumbprint = $CertificateThumbprint
CertificatePath = $CertificatePath
CertificatePassword = $CertificatePassword
Managedidentity = $ManagedIdentity.IsPresent
TenantId = $TenantId
Write-Verbose -Message "MailboxPlan $($Identity) does not exist."

$CASMailboxPlan = Get-CASMailboxPlan -Filter "Name -like '$($Identity.Split('-')[0])*'"
if ($null -eq $CASMailboxPlan)
{
Write-Verbose -Message "CASMailboxPlan $($Identity) does not exist."
return $nullResult
}
}

Write-Verbose -Message "Found CASMailboxPlan $($Identity)"
Write-Verbose -Message "Get-TargetResource Result: `n $(Convert-M365DscHashtableToString -Hashtable $result)"
return $result
$result = @{
Identity = $Identity
ActiveSyncEnabled = $CASMailboxPlan.ActiveSyncEnabled
ImapEnabled = $CASMailboxPlan.ImapEnabled
OwaMailboxPolicy = $CASMailboxPlan.OwaMailboxPolicy
PopEnabled = $CASMailboxPlan.PopEnabled
Credential = $Credential
ApplicationId = $ApplicationId
CertificateThumbprint = $CertificateThumbprint
CertificatePath = $CertificatePath
CertificatePassword = $CertificatePassword
Managedidentity = $ManagedIdentity.IsPresent
TenantId = $TenantId
}

Write-Verbose -Message "Found CASMailboxPlan $($Identity)"
Write-Verbose -Message "Get-TargetResource Result: `n $(Convert-M365DscHashtableToString -Hashtable $result)"
return $result
}
catch
{
Expand Down Expand Up @@ -217,11 +220,11 @@ function Set-TargetResource
$CASMailboxPlanParams.Remove('CertificatePassword') | Out-Null
$CASMailboxPlanParams.Remove('ManagedIdentity') | Out-Null

$CASMailboxPlans = Get-CASMailboxPlan
$CASMailboxPlan = $CASMailboxPlans | Where-Object -FilterScript { $_.Identity -eq $Identity }
$CASMailboxPlan = Get-CASMailboxPlan -Filter "Name -like '$Identity*'"

if ($null -ne $CASMailboxPlan)
{
$CasMailboxPlanParams.Identity = $CASMailboxPlan.Identity
Write-Verbose -Message "Setting CASMailboxPlan $Identity with values: $(Convert-M365DscHashtableToString -Hashtable $CASMailboxPlanParams)"
Set-CASMailboxPlan @CASMailboxPlanParams
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function Get-TargetResource
{
Write-Verbose -Message "MailboxPlan $($Identity) does not exist."

$MailboxPlan = Get-MailboxPlan -Filter "Name like '$($Identity.Split('-')[0])*'"
$MailboxPlan = Get-MailboxPlan -Filter "Name -like '$($Identity.Split('-')[0])*'"
if ($null -eq $MailboxPlan)
{
return $nullResult
Expand Down

0 comments on commit 11453ab

Please sign in to comment.