File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
src/PowerShellEditorServices/Session Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,6 @@ internal static RunspaceDetails CreateFromRunspace(
193193 Validate . IsNotNull ( nameof ( runspace ) , runspace ) ;
194194 Validate . IsNotNull ( nameof ( sessionDetails ) , sessionDetails ) ;
195195
196- var runspaceId = runspace . InstanceId ;
197196 var runspaceLocation = RunspaceLocation . Local ;
198197 var runspaceContext = RunspaceContext . Original ;
199198 var versionDetails = PowerShellVersionDetails . GetVersionDetails ( runspace , logger ) ;
@@ -218,13 +217,17 @@ internal static RunspaceDetails CreateFromRunspace(
218217 // ProcessId property isn't on the object, move on.
219218 }
220219
221- if ( runspace . ConnectionInfo . ComputerName != "localhost" )
222- {
223- runspaceId =
224- PowerShellContext . ExecuteScriptAndGetItem < Guid > (
225- "$host.Runspace.InstanceId" ,
226- runspace ) ;
220+ // Grab the $host.name which will tell us if we're in a PSRP session or not
221+ string hostName =
222+ PowerShellContext . ExecuteScriptAndGetItem < string > (
223+ "$Host.Name" ,
224+ runspace ,
225+ defaultValue : string . Empty ) ;
227226
227+ // hostname is 'ServerRemoteHost' when the user enters a session.
228+ // ex. Enter-PSSession, Enter-PSHostProcess
229+ if ( hostName . Equals ( "ServerRemoteHost" , StringComparison . Ordinal ) )
230+ {
228231 runspaceLocation = RunspaceLocation . Remote ;
229232 connectionString =
230233 runspace . ConnectionInfo . ComputerName +
You can’t perform that action at this time.
0 commit comments