Skip to content

Fix local remoting #801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 30, 2018
11 changes: 10 additions & 1 deletion src/PowerShellEditorServices/Session/RunspaceDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,16 @@ internal static RunspaceDetails CreateFromRunspace(
// ProcessId property isn't on the object, move on.
}

if (runspace.ConnectionInfo.ComputerName != "localhost")
// Grab the $host.name which will tell us if we're in a PSRP session or not
string hostname =
PowerShellContext.ExecuteScriptAndGetItem<string>(
"$host.name",
runspace,
defaultValue: "");

// hostname is 'ServerRemoteHost' when the user enters a session.
// ex. Enter-PSSession, Enter-PSHostProcess
if (hostname == "ServerRemoteHost")
{
runspaceId =

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This runspaceId variable doesn't seem to be used anywhere, and perhaps it is not needed. Also the default value returned should not be runspace, but a default runspace id.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've deleted that line of code. Thanks @PaulHigin!

PowerShellContext.ExecuteScriptAndGetItem<Guid>(
Expand Down