Private/Convert-ADsPath.ps1

function Convert-ADsPath{
    param (
        [string]$path,
        [switch]$KeepUserSuffix  # New parameter to control whether to keep the ',user' suffix
    )
    
    # Normalize the path by removing protocol and converting all characters to lowercase for consistent comparison
    $normalizedPath = $path -replace 'winnt://', '' -replace '/', '\' -replace '^\\+', '' -replace '\\+$', ''
    $normalizedPath = $normalizedPath.ToLower().Trim()
    
    # Optionally keep the ',user' suffix based on the function call parameter
    if (-not $KeepUserSuffix) {
        $normalizedPath = $normalizedPath -replace ',user$', ''  # Remove ',user' suffix if not required to keep it
    }
    
    # Removing any domain/subdomain prefix
    $parts = $normalizedPath -split '\\'
    if ($parts.Count -gt 2) {
        # Assuming the format might be domain\computer\username, return only relevant parts
        $relevantParts = $parts[-2..-1] -join '\'
        return $relevantParts
    }
    return $normalizedPath
}