Skip to content

Commit

Permalink
Merge pull request microsoft#4736 from FabienTschanz/feat/app-configu…
Browse files Browse the repository at this point in the history
…ration-device-json

Add JSON conversion to app configuration device policy
  • Loading branch information
NikCharlebois authored Jun 11, 2024
2 parents 7da3ce8 + 851eceb commit 3b9e4f5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* IntuneAppConfigurationDevicePolicy
* Add assignment group display name and fix compilation
FIXES [#4724](https://github.com/microsoft/Microsoft365DSC/issues/4724)
* Add conversion from `payloadJson` to actual JSON.
* M365DSCResourceGenerator
* Add support for generating Intune settings catalog policies.
* M365DSCDRGUtil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,17 @@ function Get-TargetResource
}
}

$payloadJson = $null
if (-not [System.String]::IsNullOrEmpty($getValue.AdditionalProperties.payloadJson))
{
$payloadJson = [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($getValue.AdditionalProperties.payloadJson))
}

$results = @{
#region resource generator code
ConnectedAppsEnabled = $getValue.AdditionalProperties.connectedAppsEnabled
PackageId = $getValue.AdditionalProperties.packageId
PayloadJson = $getValue.AdditionalProperties.payloadJson
PayloadJson = $payloadJson
PermissionActions = $complexPermissionActions
ProfileApplicability = $enumProfileApplicability
EncodedSettingXml = $getValue.AdditionalProperties.encodedSettingXml
Expand Down Expand Up @@ -362,6 +368,11 @@ function Set-TargetResource
$platform = 'ios'
}

if (-not [System.String]::IsNullOrEmpty($BoundParameters.PayloadJson))
{
$BoundParameters.PayloadJson = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($BoundParameters.PayloadJson))
}

$mobileApps = Get-MgBetaDeviceAppManagementMobileApp -All
$targetedApps = @()
foreach ($targetedApp in $TargetedMobileApps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
displayName = "FakeStringValue"
id = "FakeStringValue"
PackageId = "FakeStringValue"
PayloadJson = "FakeStringValue"
PayloadJson = "{`"test`":`"value`"}"
permissionActions = [CimInstance[]]@(
(New-CimInstance -ClassName MSFT_MicrosoftGraphandroidPermissionAction -Property @{
permission = "FakeStringValue"
Expand Down Expand Up @@ -119,7 +119,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
displayName = "FakeStringValue"
id = "FakeStringValue"
PackageId = "FakeStringValue"
PayloadJson = "FakeStringValue"
PayloadJson = "{`"test`":`"value`"}"
permissionActions = [CimInstance[]]@(
(New-CimInstance -ClassName MSFT_MicrosoftGraphandroidPermissionAction -Property @{
permission = "FakeStringValue"
Expand Down Expand Up @@ -148,7 +148,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
AdditionalProperties = @{
appSupportsOemConfig = $True
'@odata.type' = "#microsoft.graph.androidManagedStoreAppConfiguration"
payloadJson = "FakeStringValue"
payloadJson = "eyJ0ZXN0IjoidmFsdWUifQ=="
profileApplicability = "default"
permissionActions = @(
@{
Expand Down Expand Up @@ -192,7 +192,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
displayName = "FakeStringValue"
id = "FakeStringValue"
PackageId = "FakeStringValue"
PayloadJson = "FakeStringValue"
PayloadJson = "{`"test`":`"value`"}"
permissionActions = [CimInstance[]]@(
(New-CimInstance -ClassName MSFT_MicrosoftGraphandroidPermissionAction -Property @{
permission = "FakeStringValue"
Expand Down Expand Up @@ -221,7 +221,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
AdditionalProperties = @{
appSupportsOemConfig = $True
'@odata.type' = "#microsoft.graph.androidManagedStoreAppConfiguration"
payloadJson = "FakeStringValue"
payloadJson = "eyJ0ZXN0IjoidmFsdWUifQ=="
profileApplicability = "default"
permissionActions = @(
@{
Expand Down Expand Up @@ -258,7 +258,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
displayName = "FakeStringValue"
id = "FakeStringValue"
PackageId = "FakeStringValue"
PayloadJson = "FakeStringValue"
PayloadJson = "{`"test`":`"value`"}"
permissionActions = [CimInstance[]]@(
(New-CimInstance -ClassName MSFT_MicrosoftGraphandroidPermissionAction -Property @{
permission = "FakeStringValue"
Expand Down Expand Up @@ -293,7 +293,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
action = "prompt"
}
)
payloadJson = "FakeStringValue"
payloadJson = "eyJ0ZXN0IjoidmFsdWUifQ=="
}
createdDateTime = "2023-01-01T00:00:00.0000000+01:00"
description = "FakeStringValue"
Expand Down Expand Up @@ -334,7 +334,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
AdditionalProperties = @{
appSupportsOemConfig = $True
'@odata.type' = "#microsoft.graph.androidManagedStoreAppConfiguration"
payloadJson = "FakeStringValue"
payloadJson = "{`"test`":`"value`"}"
profileApplicability = "default"
permissionActions = @(
@{
Expand Down

0 comments on commit 3b9e4f5

Please sign in to comment.