Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes four Intune bugs #2787

Merged
merged 5 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

# UNRELEASED

* IntuneAppConfigurationPolicy
* Fixes issue where the Test method fails when the policy does not exist yet
and the Assignments parameter is used.
FIXES [#2768](https://github.com/microsoft/Microsoft365DSC/issues/2768)
* IntuneDeviceAndAppManagementAssignmentFilter
* Fixes issue where the code did not check for the DisplayName when the ID could not
be found.
FIXES [#2788](https://github.com/microsoft/Microsoft365DSC/issues/2788)
* IntuneDeviceConfigurationPolicyMacOS
* Corrected copy/paste issue while implementing previous fix.
FIXES [#2731](https://github.com/microsoft/Microsoft365DSC/issues/2731)
* IntuneRoleDefinition
* Fixes issue where the code did not check for the DisplayName when the ID could not
be found.
FIXES [#2771](https://github.com/microsoft/Microsoft365DSC/issues/2771)
* Updated logging logic to include more details and add Current/Target values in the
Test method.
* PlannerTask
* Refactored to leverage the official cmdlets instead of using the legacy GraphHandlers.
FIXES [#2767](https://github.com/microsoft/Microsoft365DSC/issues/2767)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ function Get-TargetResource
[Switch]
$ManagedIdentity
)
Write-Verbose -Message "Checking for the Intune App Configuration Policy {$DisplayName}"

Write-Verbose -Message "Getting configuration of Intune App Configuration Policy {$DisplayName}"
$ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' `
-InboundParameters $PSBoundParameters `
-ProfileName 'beta'
Expand All @@ -66,19 +67,21 @@ function Get-TargetResource
Add-M365DSCTelemetryEvent -Data $data
#endregion

$nullResult = $PSBoundParameters
$nullResult = @{
DisplayName = $DisplayName
}
$nullResult.Ensure = 'Absent'
try
{
$configPolicy = Get-MgDeviceAppManagementTargetedManagedAppConfiguration -Filter "displayName eq '$DisplayName'" `
-ErrorAction Stop


if ($null -eq $configPolicy)
{
Write-Verbose -Message "No App Configuration Policy with displayName {$DisplayName} was found"
return $nullResult
}

Write-Verbose -Message "Found App Configuration Policy with displayName {$DisplayName}"
$returnHashtable = @{
DisplayName = $configPolicy.DisplayName
Expand All @@ -92,6 +95,7 @@ function Get-TargetResource
CertificateThumbprint = $CertificateThumbprint
Managedidentity = $ManagedIdentity.IsPresent
}

$returnAssignments = @()
$returnAssignments += Get-MgDeviceAppManagementTargetedManagedAppConfigurationAssignment -TargetedManagedAppConfigurationId $configPolicy.Id
$assignmentResult = @()
Expand Down Expand Up @@ -172,7 +176,7 @@ function Set-TargetResource
$ManagedIdentity
)

Write-Verbose -Message "Intune App Configuration Policy {$DisplayName}"
Write-Verbose -Message "Setting configuration of Intune App Configuration Policy {$DisplayName}"

$ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' `
-InboundParameters $PSBoundParameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Get-TargetResource
$ManagedIdentity
)

Write-Verbose -Message "Checking for the assignment filter {$DisplayName}"
Write-Verbose -Message "Getting the Intune Device and App Management Assignment Filter {$DisplayName}"

$ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' `
-InboundParameters $PSBoundParameters `
Expand All @@ -80,19 +80,24 @@ function Get-TargetResource
Add-M365DSCTelemetryEvent -Data $data
#endregion

$nullResult = $PSBoundParameters
$nullResult.Ensure = 'Absent'
$nullResult = @{
DisplayName = $DisplayName
Ensure = 'Absent'
}

try
{
if (-not [System.String]::IsNullOrEmpty($Identity))
{
$assignmentFilter = Get-MgDeviceManagementAssignmentFilter -DeviceAndAppManagementAssignmentFilterId $Identity -ErrorAction Stop
Write-Verbose -Message "Checking if filter exists with identity {$Identity}."
$assignmentFilter = Get-MgDeviceManagementAssignmentFilter -DeviceAndAppManagementAssignmentFilterId $Identity -ErrorAction 'SilentlyContinue'
}
elseif ($null -eq $assignmentFilter)

if ($null -eq $assignmentFilter)
{
Write-Verbose -Message "No assignment filter with Identity {$Identity} was found."

Write-Verbose -Message "Checking if filter exists with DisplayName {$DisplayName}."
[array]$assignmentFilter = Get-MgDeviceManagementAssignmentFilter -All | Where-Object -FilterScript { $_.DisplayName -eq $DisplayName }
if ($assignmentFilter.Length -gt 2)
{
Expand All @@ -106,6 +111,7 @@ function Get-TargetResource
}

Write-Verbose -Message "Found assignment filter {$($assignmentFilter.displayName)}"

$returnHashtable = @{}
$returnHashtable.Add('Identity', $assignmentFilter.Id)
$returnHashtable.Add('DisplayName', $assignmentFilter.displayName)
Expand Down Expand Up @@ -190,6 +196,8 @@ function Set-TargetResource
$ManagedIdentity
)

Write-Verbose -Message "Setting the Intune Device and App Management Assignment Filter {$DisplayName}"

$ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' `
-InboundParameters $PSBoundParameters `
-ProfileName 'beta'
Expand Down Expand Up @@ -294,6 +302,8 @@ function Test-TargetResource
$ManagedIdentity
)

Write-Verbose -Message "Testing the Intune Device and App Management Assignment Filter {$DisplayName}"

#Ensure the proper dependencies are installed in the current environment.
Confirm-M365DSCDependencies

Expand All @@ -317,6 +327,7 @@ function Test-TargetResource
$ValuesToCheck.Remove('ApplicationId') | Out-Null
$ValuesToCheck.Remove('TenantId') | Out-Null
$ValuesToCheck.Remove('ApplicationSecret') | Out-Null
$ValuesToCheck.Remove('Identity') | Out-Null

$TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
Expand Down Expand Up @@ -394,6 +405,7 @@ function Export-TargetResource
{
Write-Host "`r`n" -NoNewline
}

foreach ($assignmentFilter in $assignmentFilters)
{
Write-Host " |---[$i/$($assignmentFilters.Count)] $($assignmentFilter.displayName)" -NoNewline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ function Get-TargetResource
SoftwareUpdatesEnforcedDelayInDays = $getValue.AdditionalProperties.softwareUpdatesEnforcedDelayInDays
SpotlightBlockInternetResults = $getValue.AdditionalProperties.spotlightBlockInternetResults
TouchIdTimeoutInHours = $getValue.AdditionalProperties.touchIdTimeoutInHours
UpdateDelayPolicy = $getValue.AdditionalProperties.updateDelayPolicy -split '-'
UpdateDelayPolicy = $getValue.AdditionalProperties.updateDelayPolicy -split ','
WallpaperModificationBlocked = $getValue.AdditionalProperties.wallpaperModificationBlocked
Ensure = 'Present'
Credential = $Credential
Expand Down
Loading