microsoft / mggraph-intune-samples

Repository to hold Microsoft Intune script samples for the Microsoft Graph PowerShell SDK
https://learn.microsoft.com/en-us/graph/api/resources/intune-graph-overview
MIT License
134 stars 31 forks source link

ManagedAppPolicy_Export.ps1 does not get many values exported to .json file #5

Closed shimojimatto closed 4 months ago

shimojimatto commented 5 months ago

It would appear that during the conversion of the policy objects to json, a lot of the property data is lost... resulting in either completely blank values or "null" values in the .json file that make the export less useful than hoped (and certainly not usable for re-import or making quick copies of policies).

Example partial json output:

{
    "AllowedDataStorageLocations":  [
                                        {

                                        },
                                        {

                                        }
                                    ],
    "AllowedInboundDataTransferSources":  {

                                          },
    "AllowedOutboundClipboardSharingLevel":  {

                                             },
    "AllowedOutboundDataTransferDestinations":  {

                                                },
    "AppDataEncryptionType":  {

                              },
    "Apps":  null,
    "Assignments":  null,

This is an example, there is more missing. Because so much is missing, the Import script also doesn't work because it can't parse "nothing". The Get-MgDeviceAppManagementiOSManagedAppProtection command is able to get all of the data on a policy, as using Format-List and some selective -ExpandProperty on a few of the Properties will show all of the data necessary. Example:

AllowedDataStorageLocations             : {oneDriveForBusiness, sharePoint}
AllowedInboundDataTransferSources       : allApps
AllowedOutboundClipboardSharingLevel    : managedAppsWithPasteIn
AllowedOutboundDataTransferDestinations : managedApps
AppDataEncryptionType                   : whenDeviceLocked
Apps                                    : {com.microsoft.azure.ios, com.microsoft.bing.halseyassistant.ios, com.microsoft.dynamics.ios, com.microsoft.dynamics.invoice.ios...}

I'm not sure how the code can be improved to make a more useful output can anyone help?

Mahopper commented 4 months ago

Hi @shimojimatto , thanks for filing this issue. I made a few improvements to both import and export scripts that should address this. Please re-open this issue if you encounter the same problem.