Description
The path length check in EntraExporter incorrectly applies a 255-character limit on Linux systems. The code checks for Windows registry key HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled, which doesn't exist on Linux, causing all paths > 255 characters to be skipped.
Affected Files
- Get-AzurePIMResources.ps1 (lines ~278, ~289)
- Get-AzurePIMDirectoryRoles.ps1 (line ~231)
- Get-AzurePIMGroups.ps1 (line ~128)
Code Pattern
if ($outputFileName.Length -gt 255 -and (Get-ItemPropertyValue HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem -Name LongPathsEnabled -ErrorAction SilentlyContinue) -ne 1)
{Write-Warning "Output file path '$outputFileName' is longer than 255 characters. Enable long path support to continue!"
return
}
Problem
- Linux supports path lengths up to ~4096 characters (only individual filename components are limited to 255)
- The registry check fails silently on Linux, always triggering the warning
- PIM Resources with long Azure resource paths are skipped entirely
Expected Behavior
- On Linux/macOS: Skip the 255-char check or use OS-appropriate limits
- Consider using shorter filenames (e.g., hash the resource ID instead of full path with & separators)
Environment
- EntraExporter Version: 3.0.1
- OS: Debian Bookworm (Linux)
- PowerShell: 7.x (pwsh)
Example Skipped Path
/home/user/backup/PIM/Resources/Subscriptions/&subscriptions&12345678-1234-1234-1234-11111111111&resourceGroups&rg-examplerg-xy-dev&providers&Microsoft.CognitiveServices&accounts&fd-example-abc-xy-dev&providers&Microsoft.Authorization&roleEligibilityScheduleRequests&1234567-1234-1234-1234-11111111111.json
Suggested Fix
# Check if running on Windows before applying Windows-specific path limit
$isWindows = $PSVersionTable.PSVersion.Major -ge 6 ? $IsWindows : $true
if ($isWindows -and $outputFileName.Length -gt 255 -and (Get-ItemPropertyValue HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem -Name LongPathsEnabled -ErrorAction SilentlyContinue) -ne 1) {
Write-Warning "Output file path '$outputFileName' is longer than 255 characters. Enable long path support to continue!"
return
}
Description
The path length check in EntraExporter incorrectly applies a 255-character limit on Linux systems. The code checks for Windows registry key HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled, which doesn't exist on Linux, causing all paths > 255 characters to be skipped.
Affected Files
Code Pattern
Problem
Expected Behavior
Environment
Example Skipped Path
/home/user/backup/PIM/Resources/Subscriptions/&subscriptions&12345678-1234-1234-1234-11111111111&resourceGroups&rg-examplerg-xy-dev&providers&Microsoft.CognitiveServices&accounts&fd-example-abc-xy-dev&providers&Microsoft.Authorization&roleEligibilityScheduleRequests&1234567-1234-1234-1234-11111111111.json
Suggested Fix