Title: When using Workingdirectory parameter on pwsh, working directory gets set AFTER execution of $PROFILE script · Issue #7895 · PowerShell/PowerShell · GitHub
Open Graph Title: When using Workingdirectory parameter on pwsh, working directory gets set AFTER execution of $PROFILE script · Issue #7895 · PowerShell/PowerShell
X Title: When using Workingdirectory parameter on pwsh, working directory gets set AFTER execution of $PROFILE script · Issue #7895 · PowerShell/PowerShell
Description: The default shortcuts for pwsh.exe on Windows are calling it using -WorkingDirectory ~ by default, which is correct and by design. However, if I wanted to temporarily change/set the final working directory, then the most intuitive way fo...
Open Graph Description: The default shortcuts for pwsh.exe on Windows are calling it using -WorkingDirectory ~ by default, which is correct and by design. However, if I wanted to temporarily change/set the final working d...
X Description: The default shortcuts for pwsh.exe on Windows are calling it using -WorkingDirectory ~ by default, which is correct and by design. However, if I wanted to temporarily change/set the final working d...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/7895
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"When using Workingdirectory parameter on pwsh, working directory gets set AFTER execution of $PROFILE script","articleBody":"The default shortcuts for pwsh.exe on Windows are calling it using `-WorkingDirectory ~` by default, which is correct and by design.\r\nHowever, if I wanted to temporarily change/set the final working directory, then the most intuitive way for most users (not familiar with this new feature) would be to add code like `cd C:\\foo` into the `$PROFILE` script.\r\nUnfortunately, only AFTER executing the script in $PROFILE, the working directory gets set to the one specified by the `WorkingDirectory` parameter. If it got set BEFORE executing the `$PROFILE` script then this problem would not exist and the working directory when $PROFILE executes would be a more reasonable one as well.\r\n\r\nSteps to reproduce\r\n------------------\r\nPut the following code into $profile\r\n```powershell\r\npwd\r\ncd C:\\\r\n```\r\n\r\nThen launch pwsh using the `-WorkingDirectory` parameter\r\n\r\nExpected behavior\r\n-----------------\r\n\r\nThe printed working directory when executing the script in $PROFILE should be the one specified by `-WorkingDirectory` of pwsh, therefore the `$PROFILE` should be able to override and change that working directory\r\n\r\nActual behavior\r\n---------------\r\n\r\nThe working directory when the `$PROFILE` script executes is `C:\\Windows\\System32` instead of the path specified by the `-WorkingDirectory` parameter on pwsh, the final working directory is not C:\\ as it is being set inside the script.\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- provide the output of $PSVersionTable --\u003e\r\n\r\n```powershell\r\n\u003e $PSVersionTable\r\n\r\nName Value\r\n---- -----\r\nPSVersion 6.1.0\r\nPSEdition Core\r\nGitCommitId 6.1.0\r\nOS Microsoft Windows 10.0.16299\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n","author":{"url":"https://github.com/bergmeister","@type":"Person","name":"bergmeister"},"datePublished":"2018-09-29T17:44:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/7895/PowerShell/issues/7895"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ff67963d-999a-f1cb-32b1-5cdc2c322c93 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 82B4:3F8BA2:1B22E:25EFF:6A579951 |
| html-safe-nonce | cb7854d90318c730e404200aeee56ed9c37a0bcefb93f28112f3fb3bb8fcb39b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkI0OjNGOEJBMjoxQjIyRToyNUVGRjo2QTU3OTk1MSIsInZpc2l0b3JfaWQiOiI4ODAzNzE2ODU3MjMwNDk4MTI5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 16b9f01c26ec453247b961e1975509fe7d65157224eb7f203b0edbdcf1cf05ba |
| hovercard-subject-tag | issue:365152388 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/7895/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fdc4df9f4e00ab9da7c3c5eac133756ee15d575cbd3fb0d0e04a8cd5346d348e/PowerShell/PowerShell/issues/7895 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fdc4df9f4e00ab9da7c3c5eac133756ee15d575cbd3fb0d0e04a8cd5346d348e/PowerShell/PowerShell/issues/7895 |
| og:image:alt | The default shortcuts for pwsh.exe on Windows are calling it using -WorkingDirectory ~ by default, which is correct and by design. However, if I wanted to temporarily change/set the final working d... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bergmeister |
| hostname | github.com |
| expected-hostname | github.com |
| None | a87fc68e9bdf22e1c7e48ac6a60b98882f4bb103314b3f26b3460c61fc5441ae |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a2198d0212ed703af207673eb4d0868d4f867a5b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width