diff --git a/CHANGELOG_macOS_IntuneToolkit.md b/CHANGELOG_macOS_IntuneToolkit.md index 9a3273a..3fb8f9b 100644 --- a/CHANGELOG_macOS_IntuneToolkit.md +++ b/CHANGELOG_macOS_IntuneToolkit.md @@ -1,5 +1,16 @@ # macOS Intune Toolkit Changelog +## 2026-11-24 — v4.4.2 — Export built-in Intune roles, fix ASCII header failure + +### Fixed +- **`Extensions/MSGraph.psm1`** / **`Extensions/MSALAuthentication.psm1`** + - Every Graph call failed with `Request headers must contain only ASCII characters` when PowerShell ran with an en-US culture: the unused `ExpiresOn` request header held a date with a U+202F space before AM/PM. Header removed (nothing reads it). + +### Changed +- **`Extensions/EndpointManager.psm1`** (Role Definitions) + - Export now includes built-in roles with their role assignments (was custom roles only). + - Import skips creating built-in roles. When *Import assignments* is enabled, their assignments are still recreated against the built-in role id (same in every tenant). Custom-role behaviour is unchanged. + ## 2026-08-07 — v4.4.1 — Reorder TUI menu into logical groups ### Changed diff --git a/Extensions/EndpointManager.psm1 b/Extensions/EndpointManager.psm1 index 1b1edcc..3562835 100644 --- a/Extensions/EndpointManager.psm1 +++ b/Extensions/EndpointManager.psm1 @@ -677,7 +677,6 @@ function Invoke-InitializeModule Id = "RoleDefinitions" ViewID = "IntuneGraphAPI" API = "/deviceManagement/roleDefinitions" - QUERYLIST = "`$filter=isBuiltIn%20eq%20false" PostExportCommand = { Start-PostExportRoleDefinitions @args } PreImportCommand = { Start-PreImportRoleDefinitions @args } PostFileImportCommand = { Start-PostFileImportRoleDefinitions @args } @@ -3499,17 +3498,38 @@ function Start-PostExportRoleDefinitions function Start-PreImportRoleDefinitions { - param($obj, $objectType) + param($obj, $objectType, $file) Remove-Property $obj "RoleAssignments" Remove-Property $obj "RoleAssignments@odata.context" + + $tmpObj = Get-GraphObjectFromFile $file + if($tmpObj.isBuiltIn -eq $true -or $tmpObj.isBuiltInRoleDefinition -eq $true) + { + # Built-in roles cannot be created and have the same id in every tenant. + # Only recreate their assignments, and only when assignments are imported. + if($global:chkImportAssignments -and $global:chkImportAssignments.IsChecked -eq $true) + { + Import-RoleDefinitionAssignments $tmpObj.Id $tmpObj + } + else + { + Write-Log "Skipping built-in role '$($tmpObj.displayName)'. Enable 'Import assignments' to import its role assignments" 2 + } + return @{ "Import" = $false } + } } function Start-PostFileImportRoleDefinitions { param($obj, $objectType, $file) - $tmpObj = Get-GraphObjectFromFile $file + Import-RoleDefinitionAssignments $obj.Id (Get-GraphObjectFromFile $file) +} + +function Import-RoleDefinitionAssignments +{ + param($roleDefinitionId, $tmpObj) $loadedScopeTags = $global:LoadedDependencyObjects["ScopeTags"] if(($tmpObj.RoleAssignments | measure).Count -gt 0 -and ($loadedScopeTags | measure).Count -gt 0) @@ -3523,7 +3543,7 @@ function Start-PostFileImportRoleDefinitions "displayName"= $roleAssignment.DisplayName "members" = $roleAssignment.members "resourceScopes" = $roleAssignment.resourceScopes - "roleDefinition@odata.bind" = "https://graph.microsoft.com/beta/deviceManagement/roleDefinitions('$($obj.Id)')" + "roleDefinition@odata.bind" = "https://graph.microsoft.com/beta/deviceManagement/roleDefinitions('$($roleDefinitionId)')" "roleScopeTags@odata.bind" = @() } diff --git a/Extensions/MSALAuthentication.psm1 b/Extensions/MSALAuthentication.psm1 index cbcfb90..18ef38e 100644 --- a/Extensions/MSALAuthentication.psm1 +++ b/Extensions/MSALAuthentication.psm1 @@ -1529,7 +1529,6 @@ public static class DeviceCodeHelper $Headers = @{ 'Content-Type' = 'application/json' 'Authorization' = "Bearer " + $tmpResults.AccessToken - 'ExpiresOn' = $tmpResults.ExpiresOn } $params = @{} diff --git a/Extensions/MSGraph.psm1 b/Extensions/MSGraph.psm1 index f5ece4d..d2f2024 100644 --- a/Extensions/MSGraph.psm1 +++ b/Extensions/MSGraph.psm1 @@ -431,7 +431,6 @@ function Invoke-GraphRequest $Headers = @{ 'Content-Type' = 'application/json; charset=utf-8' 'Authorization' = "Bearer " + $global:MSALToken.AccessToken - 'ExpiresOn' = $global:MSALToken.ExpiresOn 'x-ms-client-request-id' = $requestId } }