Title: Request / Discussion: Select-Object with one property causes many problems for beginners and has few legitimate use cases for anyone. Can that experience be improved for beginners? · Issue #5237 · PowerShell/PowerShell · GitHub
Open Graph Title: Request / Discussion: Select-Object with one property causes many problems for beginners and has few legitimate use cases for anyone. Can that experience be improved for beginners? · Issue #5237 · PowerShell/PowerShell
X Title: Request / Discussion: Select-Object with one property causes many problems for beginners and has few legitimate use cases for anyone. Can that experience be improved for beginners? · Issue #5237 · PowerShell/PowerShell
Description: I see novices posting variations of this over and over on the internet: I have this code: get-thing | select name but why are there @{} in my output and how do I get rid of them? Why doesn't the output equal -eq 'user1' ? Why doesn't my ...
Open Graph Description: I see novices posting variations of this over and over on the internet: I have this code: get-thing | select name but why are there @{} in my output and how do I get rid of them? Why doesn't the ou...
X Description: I see novices posting variations of this over and over on the internet: I have this code: get-thing | select name but why are there @{} in my output and how do I get rid of them? Why doesn't th...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/5237
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Request / Discussion: Select-Object with one property causes many problems for beginners and has few legitimate use cases for anyone. Can that experience be improved for beginners?","articleBody":"I see novices posting variations of this over and over on the internet:\r\n\r\n\u003e I have this code: `get-thing | select name` but why are there @{} in my output and how do I get rid of them? Why doesn't the output equal `-eq 'user1'` ? Why doesn't my string split/replace work on it?\r\n\r\nAnd they're too novice to understand the object pipeline well and know what it means to have an object with one property. They want the name, that looks like the way to do it, it looks like it works, but it doesn't actually do what they want.\r\n\r\nThere's lots of people tripping over this basically-useless edge-case, over and over and over on their way to learning PowerShell well.\r\n\r\nCan we come up with a way to smooth that for beginners *before* they know enough to avoid it? (i.e. putting a rule in PSScriptAnalyzer would be too late to help).\r\n\r\nIt's my suspicion that selecting one thing, `select-object -property OnePropertyHere` , is an anti-pattern, and has so few legitimate use cases that they would have to be contrived to show what it does. \r\n\r\nIdeas:\r\n\r\n - Selecting one thing should throw an exception \"you probably don't want to do that, go read a tutorial on the object pipeline\". \r\n - Selecting one thing should output a warning to the verbose stream.\r\n - `Select Name` should acted as if you specified `-ExpandProperty Name` and output a value, not an object. This would be a breaking change, but..\r\n - Then it would be useful for people who *do* know about the object pipeline as well, who still (I speculate) have few real uses for selecting an object with one property. Where the alternatives are currently the laborious `-ExpandProperty`, the convenient but ugly `|% name` or the awkward `( ).Name`, then simply `select-object -property name` would do what you most likely actually want it to do. (Downside, how would you then specify if you do want an object with one property?)\r\n - There should be another cmdlet for this use case which is clearly named to show that it won't output an object, because even \"select an object and expand a property so the output is not necessarily an object\" is a bit awkward when you stare at it for a while. e.g. `select-value` or `select-propertyvalue` or `get-objectproperty` or etc.\r\n\r\n","author":{"url":"https://github.com/HumanEquivalentUnit","@type":"Person","name":"HumanEquivalentUnit"},"datePublished":"2017-10-25T20:49:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":37},"url":"https://github.com/5237/PowerShell/issues/5237"}
| 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:569ae2fd-86b0-99ba-c424-c75affbd0d9b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9158:2FB4DB:230B6D:2E9511:6A5972FB |
| html-safe-nonce | 1161cc5caf41cca6a6e0907167eddd4adfa7341e869bf1da2a2cc679214d4bb4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MTU4OjJGQjREQjoyMzBCNkQ6MkU5NTExOjZBNTk3MkZCIiwidmlzaXRvcl9pZCI6IjY3Mzg0NDIwNDAwNzcwMjE5NDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 91b4c7160954be76854112939055f42647f99aa93807f558774cde9b2ed38057 |
| hovercard-subject-tag | issue:268544586 |
| 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/5237/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4820cedb837a8ac6b00eed9afbd802e2647fb29af5941cd8cd98914a06bbc19f/PowerShell/PowerShell/issues/5237 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4820cedb837a8ac6b00eed9afbd802e2647fb29af5941cd8cd98914a06bbc19f/PowerShell/PowerShell/issues/5237 |
| og:image:alt | I see novices posting variations of this over and over on the internet: I have this code: get-thing | select name but why are there @{} in my output and how do I get rid of them? Why doesn't the ou... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | HumanEquivalentUnit |
| hostname | github.com |
| expected-hostname | github.com |
| None | a540949572872b935b393b36db38922db390ae71c859537d741b8f3eb7e545b5 |
| 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 | 624bb50a7497aa346bef8cc3743af408a9ea10ca |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width