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
Allow configuring working directory for a new Runspace in InitialSessionState #17603
Comments
WG-Engine discussed this today. We think this overall is a good idea, just want to clarify the desired behaviour a little. We think you're suggesting that we have the runspace's Concerns were raised over mimicking your "hack" in the runspace code, we definitely don't want to be changing the process-wide current directory during runspace operations. I don't think that was what you were suggesting, but we felt we should clarify just in case. 🙂 If that matches your expectations, we'd be happy to accept a PR for this. Thanks for raising this issue! 💖 |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes. |
not completed, please reopen. |
Eh, still not completed. Could you tame your hyperactive bot? |
Summary of the new feature / enhancement
When running a PowerShell script in a new Runspace, I want to set the working directory. Currently, I cannot set it using
InitialSessionState
, and instead have to first.Open()
the Runspace and then set it by callingrunspace.SessionStateProxy.Path.SetLocation(...);
.This is
initialSessionState
, but not the working directory, even through the working directory setup is handled there (in.Bind
and.SetSessionStateDrive
),.Open()
(configured usinginitialSessionState.ImportPSModules(...)
) will see the process-wide .NET working directory, especially script modules with top-level statements.To avoid issue 2., I believe this ugly hack is currently required (which could have side-effects for other running threads):
Proposed technical implementation details (optional)
Add an
initialSessionState.WorkingDirectory
string property, initially set tonull
, which can be overwritten with a custom working directory. If unchanged, the current behavior is kept, so it should be a backwards compatible change. If the directory does not exist, throw an exception.If we agree on this solution, I could try implementing a PR.
The text was updated successfully, but these errors were encountered: