Title: Invoke-Command -SSHConnection breaks if the HostName string is [psobject]-wrapped · Issue #10687 · PowerShell/PowerShell · GitHub
Open Graph Title: Invoke-Command -SSHConnection breaks if the HostName string is [psobject]-wrapped · Issue #10687 · PowerShell/PowerShell
X Title: Invoke-Command -SSHConnection breaks if the HostName string is [psobject]-wrapped · Issue #10687 · PowerShell/PowerShell
Description: The root cause is that a string returned from a cmdlet call or external program has an invisible extra [psobject] wrapper, and the Invoke-Command cmdlet fails to take that possibility into account. In short: The command below breaks, bec...
Open Graph Description: The root cause is that a string returned from a cmdlet call or external program has an invisible extra [psobject] wrapper, and the Invoke-Command cmdlet fails to take that possibility into account....
X Description: The root cause is that a string returned from a cmdlet call or external program has an invisible extra [psobject] wrapper, and the Invoke-Command cmdlet fails to take that possibility into account....
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/10687
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Invoke-Command -SSHConnection breaks if the HostName string is [psobject]-wrapped ","articleBody":"The root cause is that a string returned from a cmdlet call or external program has an invisible extra `[psobject]` wrapper, and the `Invoke-Command` cmdlet fails to take that possibility into account.\r\n\r\nIn short: The command below breaks, because `(hostname)` has such an invisible wrapper, as evidenced by `(hostname) -is [psobject]` being `$true`.\r\n\r\nThis is yet another manifestation of our old friend #5579.\r\n\r\nThe specific problem in `Invoke-Command` is [here](https://github.com/PowerShell/PowerShell/blob/77ddec161417f98f8f2e57e9e9ef57d00cdc4c98/src/System.Management.Automation/engine/remoting/commands/PSRemotingCmdlet.cs#L1063).\r\n\r\n# Steps to reproduce\r\n\r\n```powershell\r\n{ icm -SSHConnection @{ Hostname = (hostname) } -ScriptBlock { 'hi' } } | \r\n Should -not -Throw\r\n```\r\n\r\n# Expected behavior\r\n\r\nThe test should succeed, if the local computer is set up for being a SSH remoting target.\r\n\r\n# Actual behavior\r\n\r\nThe test fails:\r\n\r\n```\r\nExpected no exception to be thrown, but an exception \r\n\"The provided SSHConnection hashtable parameter name or element is null or empty.\" was thrown from line:1 char:3\r\n```\r\n\r\nNote that using `(hostname).psobject.BaseObject` or `\"$(hostname)\"` or `(hostname).ToString()` makes the problem go away.\r\n\r\nAs an aside: if the host name were truly invalid due not being a string, the error message would be misleading, because the problem is that the entry is of the _wrong type_, not that it is _null or empty_.\r\n\r\nA further aside: The comment above the `SSHConnection` parameter definition is incomplete: keys `Port` and `Subsystem` are missing.\r\n\r\n# Environment data\r\n\r\n\r\n```none\r\nPowerShell Core v7.0.0-preview.4\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2019-10-02T20:34:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/10687/PowerShell/issues/10687"}
| 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:03cdd2bb-3141-eb0d-2cb8-818eec520672 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D790:1EBF5C:98CC60:CDF023:6A5B4AE2 |
| html-safe-nonce | 8c7e9920285b09e18b694e371da259004bdb084852b681ab0fdf432eb23277e4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzkwOjFFQkY1Qzo5OENDNjA6Q0RGMDIzOjZBNUI0QUUyIiwidmlzaXRvcl9pZCI6IjYyNzEyNTQ5MDY1NzU0NzMzNzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2880cbecf2d75452bc1a17f8b6afdfa3ec937e780e1301d1456e223b85d67ac6 |
| hovercard-subject-tag | issue:501711999 |
| 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/10687/issue_layout |
| twitter:image | https://opengraph.githubassets.com/96cc1a9093a16876c5bc5257149cbedebef4b0affdd7e476c51a2309204d4189/PowerShell/PowerShell/issues/10687 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/96cc1a9093a16876c5bc5257149cbedebef4b0affdd7e476c51a2309204d4189/PowerShell/PowerShell/issues/10687 |
| og:image:alt | The root cause is that a string returned from a cmdlet call or external program has an invisible extra [psobject] wrapper, and the Invoke-Command cmdlet fails to take that possibility into account.... |
| 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 | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| 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 | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width