-
Notifications
You must be signed in to change notification settings - Fork 523
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
Fix for issue #5566 intune app configuration policy #5673
base: Dev
Are you sure you want to change the base?
Fix for issue #5566 intune app configuration policy #5673
Conversation
Mostly fixes issue microsoft#5566 where the applications part of the policy was completely ignored. Module will now detect drift when Apps are changed, and is able to correctly recreate the policy when deleted. There seems to be a problem with MgGraph that means for now, 'update' will not work. Added verbose message for now, left code that should do the 'update' commented out. Issue has been reported here: microsoft#5671 and here https://feedbackportal.microsoft.com/feedback/idea/c0940cc8-d7da-ef11-95f6-0022484d7a88
Have added a number of missing properties for the resource and added test/create support for 'Applications' Unfortunately unable to fix 'update' due to what looks like an MgGraph issue. Added a verbose message to the code to warn the user.. reported here: microsoft#5671 and here: https://feedbackportal.microsoft.com/feedback/idea/c0940cc8-d7da-ef11-95f6-0022484d7a88 Similarly the module cannot support the 'Application Catalogue Settings' either. I can find them in Graph explorer but the related cmdlet doesn't work and cannot retrieve using invoke-mgGraph either. Issue reported here https://feedbackportal.microsoft.com/feedback/idea/f77feb49-11dc-ef11-95f6-0022484d7a88 and here microsoft#5672
@dannyKBjj You need to ensure that the command is defined in one of the stubs under Tests/unit/stubs. The unit-tests run by a PR won't have access to any modules |
…sts/unit/stubs Add MgBetaDeviceAppManagementTargetedManagedAppConfigurationApps to ests/unit/stubs
That seems to have fixed it. Thanks very much for your help! |
I'm taking a look at the not working update method. |
@dannyKBjj The following code works without issues and updates the apps on the policy: if ($null -ne $Apps)
{
$appsArray = @()
foreach ($app in $Apps)
{
if ($null -ne $app.mobileAppIdentifier.bundleID)
{
$mobileAppIdentifierHashtable = @{
'@odata.type' = "#microsoft.graph.iosMobileAppIdentifier"
bundleId = $app.mobileAppIdentifier.bundleID
}
}
if ($null -ne $app.mobileAppIdentifier.packageID)
{
$mobileAppIdentifierHashtable = @{
'@odata.type' = "#microsoft.graph.androidMobileAppIdentifier"
packageId = $app.mobileAppIdentifier.packageId
}
}
if ($null -ne $app.mobileAppIdentifier.windowsAppID)
{
$mobileAppIdentifierHashtable = @{
'@odata.type' = "#microsoft.graph.windowsAppIdentifier"
windowsAppId = $app.mobileAppIdentifier.windowsAppId
}
}
$appsArray += @{
'mobileAppIdentifier' = $mobileAppIdentifierHashtable
}
}
$appsBody = @{
appGroupType = $AppGroupType
apps = $appsArray
}
Write-Verbose -Message "Updating Apps for Intune App Configuration Policy {$DisplayName}"
$Uri = (Get-MSCloudLoginConnectionProfile -Workload MicrosoftGraph).ResourceUrl + "/beta/deviceAppManagement/targetedManagedAppConfigurations('$($currentconfigPolicy.Id)')/targetApps"
Invoke-MgGraphRequest -Method POST -Uri $Uri -Body $($appsBody | ConvertTo-Json -Depth 10) -Verbose
} I switched your Btw, please remove the |
M365TenantConfig - Example.txt I've attached an export of my test policy if you want to try yourself. The policy will create just fine using the mgBeta cmdlet. If you edit the apps and try and try and update it will fail with both my code (which I commented out) and the invoke-mgGraph method you provided... or at least it is failing at my end?! |
Should it be PATCH not POST to update an existing policy? I tried changing the code to PATCH instead, but got the same result. |
The app called Graph X-Ray it's also a good complement to the browser's dev tools |
Thanks guys, I appreciate the tips. I've been thrown in the deep-end and learning as I go along, so all help is appreciated :-D Unfortunately the provided code just doesn't seem to be working for me?! I copy&pasted it over the if ($null -ne $Apps){} in Set-TargetResource, so don't really understand what I could have done wrong (if anything). It is definitely working at your end? |
@dannyKBjj Sorry, I had a |
@FabienTschanz If you use Invoke-MgGraphRequest then you can start the Uri on "/beta..." without having to worry to which Graph endpoint you're connected to (so no need for calling Get-MSCloudLoginConnectionProfile), this way it just works for any environment out of the box as long as the resource is available for that type of cloud. |
@ricmestre Yeah that was my issue, I copy-pasted it from my test without |
Hi guys, I'm sure I'm being stupid, but I experimented a fair bit with Invoke-MgGraph myself and couldn't get it to work. I also can't get the code you kindly provided to work either... I've tried everything I can think of at this point. |
Please push the latest changes how you have them implemented in your resource, best with a descriptive visible error what's not working. Then I can take a look. |
Oh, I so now it is working!!! I guess I was being stupid. No idea what I was doing wrong before, but hey-ho. I've pushed the changes. |
...365DSC/DSCResources/MSFT_IntuneAppConfigurationPolicy/MSFT_IntuneAppConfigurationPolicy.psm1
Outdated
Show resolved
Hide resolved
...365DSC/DSCResources/MSFT_IntuneAppConfigurationPolicy/MSFT_IntuneAppConfigurationPolicy.psm1
Outdated
Show resolved
Hide resolved
...365DSC/DSCResources/MSFT_IntuneAppConfigurationPolicy/MSFT_IntuneAppConfigurationPolicy.psm1
Outdated
Show resolved
Hide resolved
...365DSC/DSCResources/MSFT_IntuneAppConfigurationPolicy/MSFT_IntuneAppConfigurationPolicy.psm1
Outdated
Show resolved
Hide resolved
...365DSC/DSCResources/MSFT_IntuneAppConfigurationPolicy/MSFT_IntuneAppConfigurationPolicy.psm1
Outdated
Show resolved
Hide resolved
.../DSCResources/MSFT_IntuneAppConfigurationPolicy/MSFT_IntuneAppConfigurationPolicy.schema.mof
Outdated
Show resolved
Hide resolved
Looks good so far. Some minor formatting with a space between if and the brackets could be added and the commented lines removed, but otherwise, it's ok. |
Thanks Fabien, do you want me to make those changes, or are we letting it slide :-) |
Personally I'd like to have those changes in, but they are not required. Feel free to update it though to make it look even cleaner 😄 |
Done |
LGTM 🚀 |
Pull Request (PR) description
Have added a number of missing properties for the resource and added test/create support for 'Applications'
Unfortunately unable to fix 'update' due to what looks like an MgGraph issue. Added a verbose message to the code to warn the user..
reported here:
#5671
and here:
https://feedbackportal.microsoft.com/feedback/idea/c0940cc8-d7da-ef11-95f6-0022484d7a88
Similarly the module cannot support the 'Application Catalogue Settings' either. I can find them in Graph explorer but the related cmdlet doesn't work and cannot retrieve using invoke-mgGraph either.
Issue reported here
https://feedbackportal.microsoft.com/feedback/idea/f77feb49-11dc-ef11-95f6-0022484d7a88
and here
#5672
This Pull Request (PR) fixes the following issues
Task list
Entry should say what was changed and how that affects users (if applicable), and
reference the issue being resolved (if applicable).