function checkPowershell()

in vscode-extension/src/extension.ts [143:182]


function checkPowershell(log: Logger): boolean {
    const platformDetails = getPlatformDetails();
    const osBitness = platformDetails.isOS64Bit ? "64-bit" : "32-bit";
    const procBitness = platformDetails.isProcess64Bit ? "64-bit" : "32-bit";
    log.write(
        `Visual Studio Code v${vscode.version} ${procBitness}`,
        `${PackageJSON.displayName} Extension v${PackageJSON.version}`,
        `Operating System: ${OperatingSystem[platformDetails.operatingSystem]} ${osBitness}`);
    log.startNewLog('normal');

    //check whether the powershell exists
    const powershellExeFinder = new PowerShellExeFinder();
    let powerShellExeDetails;
    try {
        powerShellExeDetails = powershellExeFinder.getFirstAvailablePowerShellInstallation();
    } catch (e) {
        log.writeError(`Error occurred while searching for a PowerShell executable:\n${e}`);
    }
    if (!powerShellExeDetails) {
        const message = "Unable to find PowerShell."
            + " Do you have PowerShell installed?"
            + " You can also configure custom PowerShell installations"
            + " with the 'powershell.powerShellAdditionalExePaths' setting.";

        log.writeAndShowErrorWithActions(message, [
            {
                prompt: "Get PowerShell",
                action: async () => {
                    const getPSUri = vscode.Uri.parse("https://aka.ms/get-powershell-vscode");
                    vscode.env.openExternal(getPSUri);
                },
            },
        ]);
        return false;
    }
    else {
        log.write("Have found powershell!");
        return true;
    }
}