Skip to content

Commit 9cce6ed

Browse files
TylerLeonhardtrjmholt
authored andcommitted
Fix local remoting (#801)
* consider "local remoting" as "Remote"
1 parent c0d5f0f commit 9cce6ed

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/PowerShellEditorServices/Session/RunspaceDetails.cs

+10-7
Original file line numberDiff line numberDiff 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 +

0 commit comments

Comments
 (0)