Title: Allow code to detect when it is run inside a background job, as distinct from a remoting session · Issue #11293 · PowerShell/PowerShell · GitHub
Open Graph Title: Allow code to detect when it is run inside a background job, as distinct from a remoting session · Issue #11293 · PowerShell/PowerShell
X Title: Allow code to detect when it is run inside a background job, as distinct from a remoting session · Issue #11293 · PowerShell/PowerShell
Description: Summary of the new feature/enhancement Behind the scenes, background jobs use the remoting infrastructure, which means that $PSSenderInfo is populated in both cases, and $Host.Name contains ServerRemoteHost. Currently, it isn't always po...
Open Graph Description: Summary of the new feature/enhancement Behind the scenes, background jobs use the remoting infrastructure, which means that $PSSenderInfo is populated in both cases, and $Host.Name contains ServerR...
X Description: Summary of the new feature/enhancement Behind the scenes, background jobs use the remoting infrastructure, which means that $PSSenderInfo is populated in both cases, and $Host.Name contains ServerR...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/11293
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow code to detect when it is run inside a background job, as distinct from a remoting session","articleBody":"# Summary of the new feature/enhancement\r\n\r\nBehind the scenes, background jobs use the remoting infrastructure, which means that `$PSSenderInfo` is populated in both cases, and `$Host.Name` contains `ServerRemoteHost`.\r\n\r\n**Currently, it isn't always possible to detect when code is executing in a _background job_ vs. when it is running in a true _remoting session_ - but it should be possible to do so, reliably.**\r\n\r\n# Proposed technical implementation details (optional)\r\n\r\nCurrently, `$PSSenderInfo.ConnectionString` contains the fixed string `http://localhost` in background jobs, whereas in _WinRM_-based remoting sessions the URL contains the actual host name, port number, and client PowerShell version.\r\n\r\nHowever, in _SSH_-based remoting sessions, the same fixed string is currently used, which should be considered a bug - see #11292\r\n\r\n**Once #11292 gets fixed, testing `$PSSenderInfo.ConnectionString -eq 'http://localhost'` _could_ serve as the test for detecting background jobs, but that is both obscure and technically incorrect** - though it could serve as a solution if there's a backward compatibility concern over changing the value for background jobs.\r\n\r\nSince there is no actual network connection involved in the case of background jobs (I presume), **I suggest simply setting `.ConnectionString` to `''`** (empty string).\r\n\r\n\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2019-12-08T19:27:03Z","url":"https://github.com/PowerShell/PowerShell/issues/11293"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:e45ea464-b421-4154-b49e-d1be08206575 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BA16:BB03C:1CFB04:28E396:6AFD51CE |
| html-safe-nonce | d999c316ef06cc48635ea46e9ebfa27b57432ba42af7c6278ee0b87922f51b76 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTE2OkJCMDNDOjFDRkIwNDoyOEUzOTY6NkFGRDUxQ0UiLCJ2aXNpdG9yX2lkIjoiMjY2ODI3MzYyMDEyMzIxMDE5MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 766ad9f746b7ebab91985161606d89fe588267a29a6f45b14f1f5f84f814c06e |
| hovercard-subject-tag | issue:534588021 |
| 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/11293/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b37610a0a30f6d93b63afa2553029c47e6acf05bb4da96bcd50a5e5dbd4bf075/PowerShell/PowerShell/issues/11293 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b37610a0a30f6d93b63afa2553029c47e6acf05bb4da96bcd50a5e5dbd4bf075/PowerShell/PowerShell/issues/11293 |
| og:image:alt | Summary of the new feature/enhancement Behind the scenes, background jobs use the remoting infrastructure, which means that $PSSenderInfo is populated in both cases, and $Host.Name contains ServerR... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| 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 | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width