@@ -607,13 +607,19 @@ export class SessionManager {
607
607
private getPowerShellCorePaths ( ) : string [ ] {
608
608
var paths : string [ ] = [ ] ;
609
609
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' ;
611
612
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 ( ) ) ;
615
618
616
- paths . concat ( dirs ) ;
619
+ if ( dirs ) {
620
+ paths = paths . concat ( dirs ) ;
621
+ }
622
+ }
617
623
}
618
624
619
625
return paths ;
@@ -726,6 +732,19 @@ export class SessionManager {
726
732
"Switch to Windows PowerShell (x64)" ,
727
733
( ) => { this . restartSession ( { type : SessionType . UseBuiltIn , is32Bit : false } ) } ) ;
728
734
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
+
729
748
// If the configured PowerShell path isn't being used, offer it as an option
730
749
if ( this . sessionSettings . developer . powerShellExePath !== "" &&
731
750
( this . sessionConfiguration . type !== SessionType . UsePath ||
0 commit comments