Private/Get-SPMPermissionAbbreviation.ps1

function Get-SPMPermissionAbbreviation {
    <#
    .SYNOPSIS
        Maps a SharePoint role definition name to its matrix abbreviation.
    .DESCRIPTION
        V = Full Control, B = Edit, M = Contribute, L = Read. Limited-access roles are noise
        and return $null. Unknown (custom) roles get a footnote key (C1, C2, ...) 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 'V' }
        '^(Edit|Bearbeiten)$' { return 'B' }
        '^(Contribute|Mitwirken)$' { return 'M' }
        '^(Read|Lesen)$' { return 'L' }
        '^(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] = 'C{0}' -f ($CustomRoles.Count + 1)
            }
            return $CustomRoles[$RoleName]
        }
    }
}