Private/Get-UserModulePath.ps1

function Get-UserModulePath {
    <#
    .SYNOPSIS
        Get the current user's PowerShell module directory path.
    #>

    [CmdletBinding()]
    param()
    
    if ($PSVersionTable.PSVersion.Major -ge 6) {
        # PowerShell 7.0+ Core
        return [System.IO.Path]::Combine([System.Environment]::GetFolderPath('MyDocuments'), 'PowerShell', 'Modules')
    } else {
        # Windows PowerShell 5.1
        return [System.IO.Path]::Combine([System.Environment]::GetFolderPath('MyDocuments'), 'WindowsPowerShell', 'Modules')
    }
}