private/Test-CommandVSCodeInsiders.ps1

function Test-CommandVSCodeInsiders {
    <#
    .SYNOPSIS
        Tests whether the Visual Studio Code Insiders command is available
 
    .DESCRIPTION
        Uses command discovery to locate code-insiders in the current session
        PATH. If it is not found, checks the per-user and system-wide
        code-insiders.cmd paths. Returns $true when any check succeeds;
        otherwise, returns $false. The function does not execute the command.
 
    .EXAMPLE
        PS> Test-CommandVSCodeInsiders
 
        Tests whether the Visual Studio Code Insiders command is available.
 
    .INPUTS
        None. This function does not accept pipeline input.
 
    .OUTPUTS
        System.Boolean. Returns $true when code-insiders or a known
        code-insiders.cmd path is found; otherwise, returns $false.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Version: 1.0.0
        Date: 2026-08-28
 
        The fallback checks use LOCALAPPDATA and ProgramFiles from the current
        environment.
 
    .LINK
        Test-InstallVSCodeInsiders
    #>

    [OutputType([bool])]
    param ()

    if (Get-Command -Name 'code-insiders' -ErrorAction SilentlyContinue) {
        return $true
    }

    $fallbackPaths = @(
        (Join-Path $env:LOCALAPPDATA 'Programs\Microsoft VS Code Insiders\bin\code-insiders.cmd'),
        (Join-Path $env:ProgramFiles  'Microsoft VS Code Insiders\bin\code-insiders.cmd')
    )

    foreach ($path in $fallbackPaths) {
        if (Test-Path -Path $path) {
            return $true
        }
    }

    return $false
}