Skip to content

Commit

Permalink
Merge pull request microsoft#4547 from NikCharlebois/EXOActiveSyncDev…
Browse files Browse the repository at this point in the history
…iceAccessRule

EXOActiveSyncDeviceAccessRule Fixes
  • Loading branch information
NikCharlebois authored Apr 11, 2024
2 parents af6fce8 + 35f93a3 commit 1b4c625
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# UNRELEASED

* EXOActiveSyncDeviceAccessRule
* Retrieve instance by Identity if not found by characteristic.
* EXOMailboxSettings
* Simplifyied the Setlogic and removed Timezone validation to remove checks
to regstry key which caused issues in Linux.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,34 +87,36 @@ function Get-TargetResource
try
{
$AllActiveSyncDeviceAccessRules = Get-ActiveSyncDeviceAccessRule -ErrorAction Stop

$ActiveSyncDeviceAccessRule = $AllActiveSyncDeviceAccessRules | Where-Object -FilterScript { $_.Identity -eq "$QueryString ($Characteristic)" }

if ($null -eq $ActiveSyncDeviceAccessRule)
{
Write-Verbose -Message "Active Sync Device Access Rule $($Identity) does not exist."
return $nullReturn
}
else
{
$result = @{
Identity = $ActiveSyncDeviceAccessRule.Identity
AccessLevel = $ActiveSyncDeviceAccessRule.AccessLevel
Characteristic = $ActiveSyncDeviceAccessRule.Characteristic
QueryString = $ActiveSyncDeviceAccessRule.QueryString
Ensure = 'Present'
Credential = $Credential
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
CertificatePath = $CertificatePath
CertificatePassword = $CertificatePassword
Managedidentity = $ManagedIdentity.IsPresent
}
Write-Verbose -Message "Trying to retrieve instance by Identity"
$ActiveSyncDeviceAccessRule = Get-ActiveSyncDeviceAccessRule -Identity $Identity -ErrorAction 'SilentlyContinue'

Write-Verbose -Message "Found Active Sync Device Access Rule $($Identity)"
return $result
if ($null -eq $ActiveSyncDeviceAccessRule)
{
Write-Verbose -Message "Active Sync Device Access Rule $($Identity) does not exist."
return $nullReturn
}
}
$result = @{
Identity = $ActiveSyncDeviceAccessRule.Identity
AccessLevel = $ActiveSyncDeviceAccessRule.AccessLevel
Characteristic = $ActiveSyncDeviceAccessRule.Characteristic
QueryString = $ActiveSyncDeviceAccessRule.QueryString
Ensure = 'Present'
Credential = $Credential
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
CertificatePath = $CertificatePath
CertificatePassword = $CertificatePassword
Managedidentity = $ManagedIdentity.IsPresent
}

Write-Verbose -Message "Found Active Sync Device Access Rule $($Identity)"
return $result
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
}

Mock -CommandName Get-ActiveSyncDeviceAccessRule -MockWith {
return @{
Identity = 'iOS 6.1 10B145 (WrongOS)'
AccessLevel = 'Allow'
Characteristic = 'DeviceOS'
QueryString = 'iOS 6.1 10B145'
}
return $null
}
Mock -CommandName Set-ActiveSyncDeviceAccessRule -MockWith {
return @{
Expand Down

0 comments on commit 1b4c625

Please sign in to comment.