Private/Get-SPMPermissionAbbreviation.ps1

function Get-SPMPermissionAbbreviation {
    <#
    .SYNOPSIS
        Maps a SharePoint role definition name to its matrix abbreviation.
    .DESCRIPTION
        FC = Full Control, E = Edit, C = Contribute, R = Read. Limited-access roles are
        noise and return $null. Unknown (custom) roles get a footnote key (X1, X2, ...)
        that is registered in the per-site $CustomRoles map (name -> key).
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string]$RoleName,

        [Parameter(Mandatory)]
        [hashtable]$CustomRoles
    )

    switch -Regex ($RoleName) {
        '^(Full Control|Vollzugriff)$' { return 'FC' }
        '^(Edit|Bearbeiten)$' { return 'E' }
        '^(Contribute|Mitwirken)$' { return 'C' }
        '^(Read|Lesen)$' { return 'R' }
        '^(Limited Access|Web-Only Limited Access|Eingeschr.nkter Zugriff|Beschr.nkter Zugriff|Nur Web beschr.nkter Zugriff)$' { return $null }
        default {
            if (-not $CustomRoles.ContainsKey($RoleName)) {
                $CustomRoles[$RoleName] = 'X{0}' -f ($CustomRoles.Count + 1)
            }
            return $CustomRoles[$RoleName]
        }
    }
}