Title: Fix a null reference exception when 'Runspace.DefaultRunspace' is null by daxian-dbw · Pull Request #21344 · PowerShell/PowerShell · GitHub
Open Graph Title: Fix a null reference exception when 'Runspace.DefaultRunspace' is null by daxian-dbw · Pull Request #21344 · PowerShell/PowerShell
X Title: Fix a null reference exception when 'Runspace.DefaultRunspace' is null by daxian-dbw · Pull Request #21344 · PowerShell/PowerShell
Description: PR Summary Fix #21253 Fix a null reference exception when Runspace.DefaultRunspace == null. This issue happens when the WDAC Audit feature is enabled on the client machine. Enter-PSSession will push a RemoteRunspace to the RunspaceRef in ConsoleHost, then the next input loop will use the RemoteRunspace to create a pipeline. The call to LogWDACAuditMessage happens when creating that pipeline, and at that point, we are still in the starting thread of pwsh, not a Pipeline Execution Thread, so the local-thread-storage property Runspace.DefaultRunspace is null. The fix is to check on Runspace.DefaultRunspace?.Id == 1. This PR also does some cleanup of the code. PR Checklist PR has a meaningful title Use the present tense and imperative mood when describing your changes Summarized changes 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. Breaking changes None OR Experimental feature(s) needed Experimental feature name(s): User-facing changes Not Applicable OR Documentation needed Issue filed: 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 Tooling I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
Open Graph Description: PR Summary Fix #21253 Fix a null reference exception when Runspace.DefaultRunspace == null. This issue happens when the WDAC Audit feature is enabled on the client machine. Enter-PSSession will pus...
X Description: PR Summary Fix #21253 Fix a null reference exception when Runspace.DefaultRunspace == null. This issue happens when the WDAC Audit feature is enabled on the client machine. Enter-PSSession will pus...
Opengraph URL: https://github.com/PowerShell/PowerShell/pull/21344
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:9cf3c45c-2a3f-0f9e-606f-47d75cddb3d3 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9162:781E9:2F7C70B:444CB2C:6A552FE6 |
| html-safe-nonce | 6b27fd627ef7bf297d080bbb04d18445626279079a1fbb326f0c8ea487d49e00 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MTYyOjc4MUU5OjJGN0M3MEI6NDQ0Q0IyQzo2QTU1MkZFNiIsInZpc2l0b3JfaWQiOiI3NzI0MjQ5NzE3MjcwNzIwNDg2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1003bdae11b242427196f9dad64115ada434a2910eb1832396d27078f1075171 |
| hovercard-subject-tag | pull_request:1772656779 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/PowerShell/PowerShell/pull/21344/files |
| twitter:image | https://avatars.githubusercontent.com/u/127450?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/127450?s=400&v=4 |
| og:image:alt | PR Summary Fix #21253 Fix a null reference exception when Runspace.DefaultRunspace == null. This issue happens when the WDAC Audit feature is enabled on the client machine. Enter-PSSession will pus... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | fbd8fce4d63ac394c5405faa20aa50d5c9e56b979ac43ee1b26f8e7c47c4cd89 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cf96660b44878f418b09d3d6ecde00ad62332910 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width