Skip to content

Commit 60108f5

Browse files
Merge branch 'Dev' into fix/permissions
2 parents a6c76a8 + 13d463f commit 60108f5

File tree

11 files changed

+323
-88
lines changed

11 files changed

+323
-88
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
* Fixed an issue where empty `PolicyRules` would throw an exception during Get.
77
* EXOPlace
88
* Fixes an issue with the export where it was trying to export RoomList.
9+
* IntuneAppConfigurationDevicePolicy
10+
* Added error handling with message if targeted app doesn't exist.
11+
* IntuneAppProtectionPolicyAndroid
12+
* Fixed several issues when creating and updating the policy.
13+
FIXES [#6746](https://github.com/microsoft/Microsoft365DSC/issues/6746)
14+
* IntuneAppProtectionPolicyiOS
15+
* Fixed several issues when creating and updating the policy.
16+
* IntuneAzureNetworkConnectionWindows365
17+
* Fixed the name of the Azure permission provider.
18+
* IntuneDeviceCompliancePolicyAndroidDeviceOwner
19+
* Fixed an issue where a JSON serialization warning was outputted
20+
due to the object depth exceeding two levels.
921
* TeamsChannel
1022
* Updated required permissions for read / update.
1123
* TeamsEmergencyCallRoutingPolicy

Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppConfigurationDevicePolicy/MSFT_IntuneAppConfigurationDevicePolicy.psm1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ function Get-TargetResource
204204
$targetedApps = @()
205205
foreach ($targetedApp in $getValue.TargetedMobileApps)
206206
{
207-
$app = Get-MgBetaDeviceAppManagementMobileApp -MobileAppId $targetedApp
207+
$app = Get-MgBetaDeviceAppManagementMobileApp -MobileAppId $targetedApp -ErrorAction SilentlyContinue
208+
if ($null -eq $app)
209+
{
210+
Write-Warning -Message "App [$targetedApp] was not found. Please make sure the targeted app exists."
211+
continue
212+
}
213+
208214
if ($platform -eq 'android')
209215
{
210216
$targetedApps += $app.AdditionalProperties.packageId

Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppProtectionPolicyAndroid/MSFT_IntuneAppProtectionPolicyAndroid.psm1

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,12 @@ function Get-TargetResource
445445
$policyApps = Get-MgBetaDeviceAppManagementAndroidManagedAppProtectionApp -AndroidManagedAppProtectionId $Id
446446

447447
$appsArray = @()
448-
foreach ($app in $policyApps)
448+
if ($policy.AppGroupType -eq 'selectedPublicApps')
449449
{
450-
$appsArray += $app.MobileAppIdentifier.AdditionalProperties.packageId
450+
foreach ($app in $policyApps)
451+
{
452+
$appsArray += $app.MobileAppIdentifier.AdditionalProperties.packageId
453+
}
451454
}
452455

453456
$assignmentsValues = Get-MgBetaDeviceAppManagementAndroidManagedAppProtectionAssignment -AndroidManagedAppProtectionId $policy.Id
@@ -1017,7 +1020,7 @@ function Set-TargetResource
10171020
$BoundParameters.CustomBrowserDisplayName = $ManagedBrowserValuesHash.CustomBrowserDisplayName
10181021
$BoundParameters.CustomBrowserPackageId = $ManagedBrowserValuesHash.CustomBrowserPackageId
10191022

1020-
if (($Ensure -eq 'Present') -and ($currentPolicy.Ensure -eq 'Absent'))
1023+
if ($Ensure -eq 'Present' -and $currentPolicy.Ensure -eq 'Absent')
10211024
{
10221025
$createParameters = ([Hashtable]$BoundParameters).Clone()
10231026
$createParameters.Remove('Id') | Out-Null
@@ -1029,9 +1032,9 @@ function Set-TargetResource
10291032

10301033
if ($newPolicy.Id)
10311034
{
1032-
Write-Verbose -Message "Update targetApps for Android App Protection Policy with Id {$($newpolicy.Id)} and DisplayName {$DisplayName}"
1033-
$targetApps = Get-IntuneAppProtectionPolicyAndroidAppsToHashtable -Apps $Apps
1034-
$Url = (Get-MSCloudLoginConnectionProfile -Workload MicrosoftGraph).ResourceUrl + "beta/deviceAppManagement/androidManagedAppProtections('$($policy.Id)')/targetApps"
1035+
Write-Verbose -Message "Update targetApps for Android App Protection Policy with Id {$($newPolicy.Id)} and DisplayName {$DisplayName}"
1036+
$targetApps = Get-IntuneAppProtectionPolicyAndroidAppsToHashtable -Apps $Apps -AppGroupType $AppGroupType
1037+
$Url = (Get-MSCloudLoginConnectionProfile -Workload MicrosoftGraph).ResourceUrl + "beta/deviceAppManagement/androidManagedAppProtections('$($newPolicy.Id)')/targetApps"
10351038
Invoke-MgGraphRequest -Method POST -Uri $Url -Body $targetApps
10361039

10371040
$assignmentsHash = ConvertTo-IntunePolicyAssignment -IncludeDeviceFilter:$true -Assignments $Assignments
@@ -1041,7 +1044,7 @@ function Set-TargetResource
10411044
-Repository 'deviceAppManagement/androidManagedAppProtections'
10421045
}
10431046
}
1044-
elseif (($Ensure -eq 'Present') -and ($currentPolicy.Ensure -eq 'Present'))
1047+
elseif ($Ensure -eq 'Present' -and $currentPolicy.Ensure -eq 'Present')
10451048
{
10461049
$updateParameters = ([Hashtable]$BoundParameters).Clone()
10471050
$updateParameters.Remove('Id') | Out-Null
@@ -1052,7 +1055,7 @@ function Set-TargetResource
10521055
Update-MgBetaDeviceAppManagementAndroidManagedAppProtection -AndroidManagedAppProtectionId $currentPolicy.Id -BodyParameter $updateParameters
10531056

10541057
Write-Verbose -Message "Update targetApps for Android App Protection Policy with Id {$($currentPolicy.Id)} and DisplayName {$DisplayName}"
1055-
$targetApps = Get-IntuneAppProtectionPolicyAndroidAppsToHashtable -Apps $Apps
1058+
$targetApps = Get-IntuneAppProtectionPolicyAndroidAppsToHashtable -Apps $Apps -AppGroupType $AppGroupType
10561059
$Url = (Get-MSCloudLoginConnectionProfile -Workload MicrosoftGraph).ResourceUrl + "beta/deviceAppManagement/androidManagedAppProtections('$($currentPolicy.Id)')/targetApps"
10571060
Invoke-MgGraphRequest -Method POST -Uri $Url -Body $targetApps
10581061

@@ -1457,8 +1460,17 @@ function Test-TargetResource
14571460
Add-M365DSCTelemetryEvent -Data $data
14581461
#endregion
14591462

1463+
$postProcessingScript = {
1464+
param($DesiredValues, $CurrentValues, $ValuesToCheck, $ignore)
1465+
if ($DesiredValues.AppGroupType -ne 'SelectedPublicApps')
1466+
{
1467+
$ValuesToCheck.Remove('Apps')
1468+
}
1469+
return [System.Tuple[Hashtable, Hashtable, Hashtable]]::new($DesiredValues, $CurrentValues, $ValuesToCheck)
1470+
}
14601471
$result = Test-M365DSCTargetResource -DesiredValues $PSBoundParameters `
1461-
-ResourceName $($MyInvocation.MyCommand.Source).Replace('MSFT_', '')
1472+
-ResourceName $($MyInvocation.MyCommand.Source).Replace('MSFT_', '') `
1473+
-PostProcessing $postProcessingScript
14621474
return $result
14631475
}
14641476

@@ -1611,26 +1623,67 @@ function Get-IntuneAppProtectionPolicyAndroidAppsToHashtable
16111623
{
16121624
[CmdletBinding()]
16131625
[OutputType([System.Collections.Hashtable])]
1614-
param(
1626+
param
1627+
(
16151628
[Parameter(Mandatory = $true)]
1629+
[AllowEmptyCollection()]
16161630
[System.String[]]
1617-
$Apps
1631+
$Apps,
1632+
1633+
[Parameter(Mandatory = $true)]
1634+
[ValidateSet('selectedPublicApps', 'allCoreMicrosoftApps', 'allMicrosoftApps','allApps')]
1635+
[System.String]
1636+
$AppGroupType
16181637
)
16191638

16201639
$formattedApps = @()
1640+
$allApps = (Get-MgBetaDeviceAppManagementManagedAppStatus -ManagedAppStatusId managedAppList).AdditionalProperties.content.appList | Where-Object {
1641+
$_.appIdentifier.'@odata.type' -eq '#microsoft.graph.androidMobileAppIdentifier'
1642+
}
1643+
1644+
switch ($AppGroupType)
1645+
{
1646+
'selectedPublicApps'
1647+
{
1648+
if ($Apps.Count -eq 0)
1649+
{
1650+
throw "AppGroupType is set to 'selectedPublicApps' but no Apps were provided."
1651+
}
1652+
}
1653+
'allCoreMicrosoftApps'
1654+
{
1655+
$Apps = $allApps | Where-Object appGroups -EQ 'coreMicrosoft' | ForEach-Object {
1656+
$_.appIdentifier.bundleId
1657+
}
1658+
}
1659+
'allMicrosoftApps'
1660+
{
1661+
$Apps = $allApps | Where-Object appGroups -EQ 'microsoft' | ForEach-Object {
1662+
$_.appIdentifier.bundleId
1663+
}
1664+
}
1665+
'allApps'
1666+
{
1667+
$Apps = $allApps | ForEach-Object {
1668+
$_.appIdentifier.bundleId
1669+
}
1670+
}
1671+
}
1672+
16211673
foreach ($app in $Apps)
16221674
{
16231675
$formattedApps += @{
16241676
id = $app + '.android'
16251677
mobileAppIdentifier = @{
1626-
'@odata.type' = '#microsoft.graph.AndroidMobileAppIdentifier'
1678+
'@odata.type' = '#microsoft.graph.androidMobileAppIdentifier'
16271679
packageId = $app
16281680
}
16291681
}
16301682
}
16311683

16321684
return @{
16331685
apps = $formattedApps
1686+
appGroupType = $AppGroupType
16341687
}
16351688
}
16361689

Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppProtectionPolicyAndroid/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"Get-MgBetaDeviceAppManagementAndroidManagedAppProtection",
7171
"Get-MgBetaDeviceAppManagementAndroidManagedAppProtectionApp",
7272
"Get-MgBetaDeviceAppManagementAndroidManagedAppProtectionAssignment",
73+
"Get-MgBetaDeviceAppManagementManagedAppStatus",
7374
"New-MgBetaDeviceAppManagementAndroidManagedAppProtection",
7475
"Remove-MgBetaDeviceAppManagementAndroidManagedAppProtection",
7576
"Update-MgBetaDeviceAppManagementAndroidManagedAppProtection"
@@ -82,4 +83,4 @@
8283
]
8384
}
8485
]
85-
}
86+
}

0 commit comments

Comments
 (0)