File tree 1 file changed +10
-7
lines changed
src/PowerShellEditorServices/Session
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(
193
193
Validate . IsNotNull ( nameof ( runspace ) , runspace ) ;
194
194
Validate . IsNotNull ( nameof ( sessionDetails ) , sessionDetails ) ;
195
195
196
- var runspaceId = runspace . InstanceId ;
197
196
var runspaceLocation = RunspaceLocation . Local ;
198
197
var runspaceContext = RunspaceContext . Original ;
199
198
var versionDetails = PowerShellVersionDetails . GetVersionDetails ( runspace , logger ) ;
@@ -218,13 +217,17 @@ internal static RunspaceDetails CreateFromRunspace(
218
217
// ProcessId property isn't on the object, move on.
219
218
}
220
219
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 ) ;
227
226
227
+ // hostname is 'ServerRemoteHost' when the user enters a session.
228
+ // ex. Enter-PSSession, Enter-PSHostProcess
229
+ if ( hostName . Equals ( "ServerRemoteHost" , StringComparison . Ordinal ) )
230
+ {
228
231
runspaceLocation = RunspaceLocation . Remote ;
229
232
connectionString =
230
233
runspace . ConnectionInfo . ComputerName +
You can’t perform that action at this time.
0 commit comments