Private/ConvertTo-NSPConditionalAccessNameKey.ps1
|
function ConvertTo-NSPConditionalAccessNameKey { <# .SYNOPSIS A policy display name reduced to what identifies it, so older naming variants compare equal. .DESCRIPTION Lowercase; leading 'NSP -' and 'Pre -' prefixes removed (repeatedly); parenthetical notes removed; '&' read as 'and'; every other run of punctuation or spaces is one space. 'Pre - NSP - Intune - MFA for Join' and 'NSP - Admin - MFA Policy (Exempt Admin)' become 'intune mfa for join' and 'admin mfa policy', the keys of the legacy names. #> [CmdletBinding()] [OutputType([string])] param([AllowEmptyString()][string]$Name) $key = $Name.ToLowerInvariant() -replace '\([^)]*\)', ' ' -replace '&', ' and ' $key = ($key -replace '[^a-z0-9]+', ' ').Trim() while ($key -match '^(nsp|pre) (?<rest>.+)$') { $key = $Matches.rest } $key } |