microsoftgraph / powershell-intune-samples

This repository of PowerShell sample scripts show how to access Intune service resources. They demonstrate this by making HTTPS RESTful API requests to the Microsoft Graph API from PowerShell.
MIT License
1.36k stars 657 forks source link

Application_iOS_Add.ps1 has couple of bugs #262

Open breakpoint7 opened 9 months ago

breakpoint7 commented 9 months ago

Integrating Application_iOS_Add.ps1 into some automation scripts, I kept getting errors from the JSON being generated. I ended up making a few changes in order to get it to generate a correct payload: Changed: $iconType = $iconResponse.Headers["Content-Type"] to $iconType = $iconResponse.Headers["Content-Type"][0]

and the logic for setting minimum version did not work , so the min version was always false for every item. Updated as follows: minimumSupportedOperatingSystem=@{ "@odata.type" = "microsoft.graph.iosMinimumOperatingSystem"
v8_0=$osVersion -lt 9.0; v9_0=$osVersion.ToString().StartsWith("9") v10_0=$osVersion.ToString().StartsWith("10") v11_0=$osVersion.ToString().StartsWith("11") v12_0=$osVersion.ToString().StartsWith("12") v13_0=$osVersion.ToString().StartsWith("13") v14_0=$osVersion.ToString().StartsWith("14") v15_0=$osVersion.ToString().StartsWith("15") v16_0=$osVersion.ToString().StartsWith("16")
};

After making these changes, the payloads worked as expected.