feat(roles): export built-in Intune roles; fix ASCII header failure
- Drop the ExpiresOn request header. Under an en-US culture its date contains U+202F before AM/PM, so every Graph call failed with "Request headers must contain only ASCII characters". Nothing reads it. - Export all role definitions with their assignments, including built-in roles (was custom only via isBuiltIn eq false). - On import, skip creating built-in roles. When Import assignments is on, recreate their assignments against the exported role id (built-in ids are identical across tenants). Custom-role behaviour is unchanged.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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" = @()
|
||||
}
|
||||
|
||||
|
||||
@@ -1529,7 +1529,6 @@ public static class DeviceCodeHelper
|
||||
$Headers = @{
|
||||
'Content-Type' = 'application/json'
|
||||
'Authorization' = "Bearer " + $tmpResults.AccessToken
|
||||
'ExpiresOn' = $tmpResults.ExpiresOn
|
||||
}
|
||||
|
||||
$params = @{}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user