Private/Get-AppMainExecutable.ps1

function Get-AppMainExecutable {
    param([string]$AppPath)

    $infoPlist = Join-Path $AppPath "Contents/Info.plist"
    $exeName   = Get-PlistValue -PlistPath $infoPlist -Key "CFBundleExecutable"

    if ([string]::IsNullOrWhiteSpace($exeName)) {
        return $null
    }

    $exePath = Join-Path $AppPath "Contents/MacOS/$exeName"

    if (Test-Path -LiteralPath $exePath) {
        return $exePath
    }

    return $null
}