@@ -607,13 +607,19 @@ export class SessionManager {
607607 private getPowerShellCorePaths ( ) : string [ ] {
608608 var paths : string [ ] = [ ] ;
609609 if ( this . isWindowsOS ) {
610- const rootInstallPath = process . env . ProgramFiles + '\\PowerShell'
610+ const is64Bit = process . env . hasOwnProperty ( 'PROCESSOR_ARCHITEW6432' ) ;
611+ const rootInstallPath = ( is64Bit ? process . env . ProgramW6432 : process . env . ProgramFiles ) + '\\PowerShell' ;
611612
612- var dirs =
613- fs . readdirSync ( rootInstallPath )
614- . filter ( file => fs . lstatSync ( path . join ( rootInstallPath , file ) ) . isDirectory ( ) ) ;
613+ if ( fs . existsSync ( rootInstallPath ) ) {
614+ var dirs =
615+ fs . readdirSync ( rootInstallPath )
616+ . map ( item => path . join ( rootInstallPath , item ) )
617+ . filter ( item => fs . lstatSync ( item ) . isDirectory ( ) ) ;
615618
616- paths . concat ( dirs ) ;
619+ if ( dirs ) {
620+ paths = paths . concat ( dirs ) ;
621+ }
622+ }
617623 }
618624
619625 return paths ;
@@ -726,6 +732,19 @@ export class SessionManager {
726732 "Switch to Windows PowerShell (x64)" ,
727733 ( ) => { this . restartSession ( { type : SessionType . UseBuiltIn , is32Bit : false } ) } ) ;
728734
735+ var pscorePaths = this . getPowerShellCorePaths ( ) ;
736+ for ( var pscorePath of pscorePaths ) {
737+ var pscoreVersion = path . parse ( pscorePath ) . base ;
738+ var pscoreExePath = path . join ( pscorePath , "powershell.exe" ) ;
739+ var pscoreItem = new SessionMenuItem (
740+ `Switch to PowerShell Core ${ pscoreVersion } ` ,
741+ ( ) => { this . restartSession ( {
742+ type : SessionType . UsePath , path : pscoreExePath , isWindowsDevBuild : false } )
743+ } ) ;
744+
745+ menuItems . push ( pscoreItem ) ;
746+ }
747+
729748 // If the configured PowerShell path isn't being used, offer it as an option
730749 if ( this . sessionSettings . developer . powerShellExePath !== "" &&
731750 ( this . sessionConfiguration . type !== SessionType . UsePath ||
0 commit comments