GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [feature] Add -CustomPipeName to `pwsh` and `Enter-PSHostProcess` by TylerLeonhardt · Pull Request #8889 · PowerShell/PowerShell

Conversation

@TylerLeonhardt

@TylerLeonhardt TylerLeonhardt commented Feb 13, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

PR Summary

This allows a user to start PowerShell up with the name of the named pipe that is used for cross process communication (I.e. Enter-PSHostProcess).

Example:

terminal 1

pwsh -custompipename mypipe

terminal 2

Enter-PSHostProcess -CustomPipeName mypipe

PR Context

Today, it is impossible to predictively connect to a PowerShell process without knowing its process id. If you're stopping and starting a powershell process often... you have no mechanism for figuring out the process id.

This introduces a consistent way to connect to a PowerShell process by specifying the NamedPipe yourself.

This is very nice in PowerShell hosted scenarios - for example, in Azure Functions where PowerShell is hosted. This enables the ability to consistently connect to the PowerShell instance hosted there without any additional information besides the CustomPipeName that can be reused.

This feature also means that in the PowerShell extension for VSCode, we can achieve "Attach to Process" debugging with a single stroke of the F5 key.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: or [ WIP ] to the beginning of the title (the WIP bot will keep its status check at Pending while the prefix is present) and remove the prefix when the PR is ready.
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed: Doc new -CustomPipeName parameter on pwsh and Enter-PSHostProcess MicrosoftDocs/PowerShell-Docs#3755
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
      • Add [feature] to your commit messages if the change is significant or affects feature tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kvprasoon and chuanjiao10 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@TylerLeonhardt
TylerLeonhardt requested review from Bruce Payette (BrucePay), Paul Higinbotham (PaulHigin), Andrew (anmenaga), Dongbo Wang (daxian-dbw) and Mike Richmond (mirichmo) as code owners February 13, 2019 19:44
@TylerLeonhardt
TylerLeonhardt requested a review from Steve Lee (SteveL-MSFT) February 13, 2019 19:48
SteveL-MSFT
Steve Lee (SteveL-MSFT) requested changes Feb 14, 2019
View reviewed changes
Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

PaulHigin
Paul Higinbotham (PaulHigin) suggested changes Feb 14, 2019
View reviewed changes

@PaulHigin Paul Higinbotham (PaulHigin) left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I will finish the review later, but have a couple of comments now.
Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/Microsoft.PowerShell.ConsoleHost/resources/CommandLineParameterParserStrings.resx Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/hostifaces/LocalConnection.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

iSazonov
Ilya (iSazonov) reviewed Feb 14, 2019
View reviewed changes
Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/InitialSessionState.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/powershell/Modules/Microsoft.PowerShell.Core/Enter-PSHostProcess.Tests.ps1 Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/powershell/Modules/Microsoft.PowerShell.Core/Enter-PSHostProcess.Tests.ps1 Resolved

Uh oh!

There was an error while loading. Please reload this page.

PaulHigin
Paul Higinbotham (PaulHigin) suggested changes Feb 14, 2019
View reviewed changes

@PaulHigin Paul Higinbotham (PaulHigin) left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Let's remove the connection of pipe listener creation to local runspace, and think about whether we want to replace the existing default IPC channel or create a second one when starting powershell.exe in DebugPipeName mode, although I think we should use a different name for the switch, like IPCPipe or CustomIPCPipe, or something.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/System.Management.Automation/engine/hostifaces/LocalConnection.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@TylerLeonhardt TylerLeonhardt changed the title [feature] Add -DebugPipeName to pwsh and Enter-PSHostProcess [feature] [WIP] Add -DebugPipeName to pwsh and Enter-PSHostProcess Feb 15, 2019
@TylerLeonhardt

TylerLeonhardt commented Feb 15, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Paul Higinbotham (@PaulHigin) I've refactored this quite a bit based on your offline feedback. The same experience is there for a user at the CLI.

For users that are going through the API, the can use:

S.M.A.Remoting.RemoteSessionNamedPipeServer.CreateCustomNamedPipeServer("mypipe");

There is 1 thing left to do here:

  • change the name from DebugPipeName to CustomPipeName - everyone feel free to comment changed

  • figure out what should happen when this static function is called multiple times - Should it throw? Or should it overwrite? I've added it to dispose of the current server and recreate the new one

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TylerLeonhardt added 8 commits February 15, 2019 15:54
@TylerLeonhardt
Add DebugPipeName capability
51efb81
@TylerLeonhardt
[feature] minor fix for Windows
37f0956
@TylerLeonhardt
[feature] misc code factor fixes
a27b6b5
@TylerLeonhardt
[feature] add more tests and pass command down to ServerMode
6689e89
@TylerLeonhardt
[feature] fix path for Windows
6e7578c
@TylerLeonhardt
[feature] add erroraction stop and rely on a better way to wait
5d03cb6
@TylerLeonhardt
refactor to a static public method
7fa9459
@TylerLeonhardt
[feature] change test casing
d7df174
@TylerLeonhardt
TylerLeonhardt force-pushed the debugpipename-enterpshostprocess branch from d47a632 to d7df174 Compare February 15, 2019 23:55
@TylerLeonhardt
dispose of the server if we recall the function
79eabb2
@TylerLeonhardt TylerLeonhardt changed the title [feature] [WIP] Add -DebugPipeName to pwsh and Enter-PSHostProcess [feature] Add -DebugPipeName to pwsh and Enter-PSHostProcess Feb 16, 2019
PaulHigin
Paul Higinbotham (PaulHigin) suggested changes Feb 19, 2019
View reviewed changes
Comment thread src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

daxian-dbw
Dongbo Wang (daxian-dbw) reviewed Feb 19, 2019
View reviewed changes
Comment thread src/Microsoft.PowerShell.ConsoleHost/resources/CommandLineParameterParserStrings.resx Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

TylerLeonhardt added 2 commits February 19, 2019 22:03
@TylerLeonhardt
address all feedback
f8ab953
@TylerLeonhardt
[feature] add test for API and help text
25fbad7
@TylerLeonhardt

TylerLeonhardt commented Feb 20, 2019

Copy link
Copy Markdown
Member Author

Addressed all feedback 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

PaulHigin
Paul Higinbotham (PaulHigin) approved these changes Feb 20, 2019
View reviewed changes

@PaulHigin Paul Higinbotham (PaulHigin) left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. But please create new Issue about disposing pipe server objects on process exit (please see comment).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@TylerLeonhardt TylerLeonhardt mentioned this pull request Feb 20, 2019
Investigate/code clean up ifdef in RemoteSessionNamedPipe.cs #8925
Closed
@TylerLeonhardt

TylerLeonhardt commented Feb 21, 2019

Copy link
Copy Markdown
Member Author

Ok I included a few CodeFactor and Codacy fixes as well. This should be good to go pending CI ✅

vexx32 reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

iSazonov
Ilya (iSazonov) reviewed Feb 21, 2019
View reviewed changes
Comment thread src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/powershell/Modules/Microsoft.PowerShell.Core/Enter-PSHostProcess.Tests.ps1 Resolved

Uh oh!

There was an error while loading. Please reload this page.

@TylerLeonhardt
Change DebugPipeName to CustomPipeName
73cd2ce
@TylerLeonhardt

TylerLeonhardt commented Feb 21, 2019

Copy link
Copy Markdown
Member Author

I've addressed Paul Higinbotham (@PaulHigin)'s final point which is that DebugPipeName is not totally accurate as this pipe could be used for other IPC scenarios.

It's mostly used for debugging though... and our usecase is really for debugging... so I've called this out in the -help page.

His recommendation and what I went with was CustomPipeName. I've updated that throughout.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TylerLeonhardt TylerLeonhardt changed the title [feature] Add -DebugPipeName to pwsh and Enter-PSHostProcess [feature] Add -CustomPipeName to pwsh and Enter-PSHostProcess Feb 21, 2019
@TylerLeonhardt
[feature] touch up summary
636c401
iSazonov
Ilya (iSazonov) reviewed Feb 21, 2019
View reviewed changes
Comment thread src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs
case ProcessIdParameterSet:
Process = GetProcessById(Id);
VerifyProcess(Process);
namedPipeRunspace = CreateNamedPipeRunspace(Process.Id, AppDomainName);

@iSazonov Ilya (iSazonov) Feb 21, 2019

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Interesting, do we really need the VerifyProcess() check (that is File.Exist())? Perhaps the runtime error is informative enough.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@TylerLeonhardt TylerLeonhardt Feb 21, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm not quite sure what you're saying. This VerifyProcess is to keep the behavior consistent with the current behavior for Process parameter sets.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iSazonov

Ilya (iSazonov) commented Feb 21, 2019

Copy link
Copy Markdown
Collaborator

TylerLeonhardt Please create new Issue in PowerShell-Docs repo and add reference to the PR description.

daxian-dbw and TylerLeonhardt reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TylerLeonhardt added 5 commits February 21, 2019 14:11
@TylerLeonhardt
move API tests to xUnit
f8260cf
@TylerLeonhardt
[feature] Add ParallelXUnitResults.xml
d79da98
@TylerLeonhardt
[feature] remove debug log
5549bd8
@TylerLeonhardt
[feature] switch to Start-Process
d9d1779
@TylerLeonhardt
misc codacy fixes
1edba6c
@TylerLeonhardt

TylerLeonhardt commented Feb 22, 2019

Copy link
Copy Markdown
Member Author

Alright CI is green and codacy and Code Factor are mostly happy. This should be good to go.

vexx32 reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

iSazonov
Ilya (iSazonov) approved these changes Feb 22, 2019
View reviewed changes

@iSazonov Ilya (iSazonov) left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM with minor comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/xUnit/csharp/test_NamedPipe.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/xUnit/csharp/test_NamedPipe.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@TylerLeonhardt
[feature] address Ilya's comments
9c3dfb3
@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Feb 22, 2019
@iSazonov

Ilya (iSazonov) commented Feb 22, 2019

Copy link
Copy Markdown
Collaborator

TylerLeonhardt Please create new Issue in PowerShell-Docs repo before we merge.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TylerLeonhardt TylerLeonhardt mentioned this pull request Feb 22, 2019
Doc new -CustomPipeName parameter on pwsh and Enter-PSHostProcess MicrosoftDocs/PowerShell-Docs#3755
Closed
2 of 8 tasks
@TylerLeonhardt

TylerLeonhardt commented Feb 22, 2019

Copy link
Copy Markdown
Member Author

Done, Ilya (@iSazonov)!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov Ilya (iSazonov) self-assigned this Feb 22, 2019
@iSazonov
Ilya (iSazonov) merged commit 23eccfd into PowerShell:master Feb 22, 2019
@iSazonov

Ilya (iSazonov) commented Feb 22, 2019

Copy link
Copy Markdown
Collaborator

TylerLeonhardt Thanks for your contribution!

TylerLeonhardt reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TylerLeonhardt
TylerLeonhardt deleted the debugpipename-enterpshostprocess branch February 23, 2019 01:35
This was referenced Feb 27, 2019
Support -CustomPipeName PowerShell/PowerShellEditorServices#871
Merged
Support -CustomPipeName PowerShell/vscode-powershell#1775
Merged
@joeyaiello Joey Aiello (joeyaiello) added this to the 6.2.0 milestone Mar 22, 2019
This was referenced Mar 22, 2019
update docs for -CustomPipeName MicrosoftDocs/PowerShell-Docs#4032
Merged
Typo in new parameter set #9205
Merged
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@TylerLeonhardt @iSazonov
[feature] Add -CustomPipeName to pwsh and Enter-PSHostProcess (Po…
788d400
…werShell#8889)

This allows a user to start PowerShell up with the name of the named pipe that is used for cross process communication (I.e. Enter-PSHostProcess).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@SteveL-MSFT Steve Lee (SteveL-MSFT) SteveL-MSFT approved these changes
@daxian-dbw Dongbo Wang (daxian-dbw) daxian-dbw approved these changes
@iSazonov Ilya (iSazonov) iSazonov approved these changes
@anmenaga Andrew (anmenaga) Awaiting requested review from anmenaga
@BrucePay Bruce Payette (BrucePay) Awaiting requested review from BrucePay
@mirichmo Mike Richmond (mirichmo) Awaiting requested review from mirichmo
+1 more reviewer
@PaulHigin Paul Higinbotham (PaulHigin) PaulHigin approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@iSazonov Ilya (iSazonov)

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Milestone

6.2.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@TylerLeonhardt @iSazonov @daxian-dbw @SteveL-MSFT @PaulHigin @joeyaiello
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.