Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,17 +492,22 @@ export class SessionManager implements Middleware {
let foundPowerShell: IPowerShellExeDetails | undefined;
try {
let defaultPowerShell: IPowerShellExeDetails | undefined;
if (this.sessionSettings.powerShellDefaultVersion !== "") {
const wantedName = this.sessionSettings.powerShellDefaultVersion;
if (wantedName !== "") {
for await (const details of powershellExeFinder.enumeratePowerShellInstallations()) {
// Need to compare names case-insensitively, from https://stackoverflow.com/a/2140723
const wantedName = this.sessionSettings.powerShellDefaultVersion;
if (wantedName.localeCompare(details.displayName, undefined, { sensitivity: "accent" }) === 0) {
defaultPowerShell = details;
break;
}
}

}
foundPowerShell = defaultPowerShell ?? await powershellExeFinder.getFirstAvailablePowerShellInstallation();
if (defaultPowerShell === undefined && foundPowerShell !== undefined) {
void this.logger.writeAndShowWarning(`The 'powerShellDefaultVersion' setting was '${wantedName}' but this was not found!`
+ ` Instead using first available installation '${foundPowerShell.displayName}' at '${foundPowerShell.exePath}'!`);
}
} catch (e) {
this.logger.writeError(`Error occurred while searching for a PowerShell executable:\n${e}`);
}
Expand Down