Title: Negative values provided to the `Get-Content` `-Tail` parameter no longer return the entire content, and instead print an error · Issue #21347 · PowerShell/PowerShell · GitHub
Open Graph Title: Negative values provided to the `Get-Content` `-Tail` parameter no longer return the entire content, and instead print an error · Issue #21347 · PowerShell/PowerShell
X Title: Negative values provided to the `Get-Content` `-Tail` parameter no longer return the entire content, and instead print an error · Issue #21347 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/21347
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Negative values provided to the `Get-Content` `-Tail` parameter no longer return the entire content, and instead print an error","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\nNegative values for `Get-Content` parameter `-Tail` are no longer considered valid, despite the documentation specifying that the accepted type is Int32 which supports negative values, and that providing a negative value results in an unlimited number of lines, effectively showing the full content of the file regardless of its length, even if that length is above `$([int]::MaxValue)`.\r\n\r\nThe [latest documentation for this command](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-content?view=powershell-7.5) says this in the `-Tail` section:\r\n\r\n\u003e Negative values cause the cmdlet to return the entire contents.\r\n\r\nSo, it looks like the current behavior does not match the documented behavior.\r\n\r\nI see no current equivalent way to guarantee getting a truly unlimited number of lines beyond `$([int]::MaxValue)`. That returns a very large number, but does not guarantee all lines if the file has more lines than `$([int]::MaxValue)`.\r\n\r\n### Expected behavior\r\n\r\n```console\r\nPS\u003e Get-Content ${filePath} -Wait -Tail -1\r\n\u003cfull content of the file at ${filePath} shown here\u003e\r\n```\r\n\r\n\r\n### Observed behavior\r\n\r\n```console\r\nPS\u003e Get-Content ${filePath} -Wait -Tail -1\r\nGet-Content: Cannot validate argument on parameter 'Tail'. The -1 argument is less than the minimum allowed range of 0. Supply an argument that is greater than or equal to 0 and then try the command again.\r\n```\r\n\r\n\r\n### Error details\r\n\r\nI am submitting this issue report on a different computer from the one in which I discovered this issue, so I don't have direct copy access to the output of `Get-Error`. The error says `Get-Content: Cannot validate argument on parameter 'Tail'. The -1 argument is less than the minimum allowed range of 0. Supply an argument that is greater than or equal to 0 and then try the command again.` though.\r\n\r\n\r\n### Environment data\r\n\r\nI am submitting this issue report on a different computer from the one in which I discovered this issue, so I don't have direct copy access to the output of ${PSVersionTable}. It says the version is `7.4.1` though.","author":{"url":"https://github.com/BujuArena","@type":"Person","name":"BujuArena"},"datePublished":"2024-03-15T19:27:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/21347/PowerShell/issues/21347"}
| 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:7efaa59d-affc-141e-dcb1-9c0d5193b52f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D12E:272B2:504988:6E7FE9:6A58508F |
| html-safe-nonce | 6a5ccce7b8d594d6fae7169713b7149f48faaa9c0b6b32908dba2011eb0b4c9b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTJFOjI3MkIyOjUwNDk4ODo2RTdGRTk6NkE1ODUwOEYiLCJ2aXNpdG9yX2lkIjoiODE5NDQxOTUyMDg3NjA3MzEwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b9a413c306ffca7496fea034075189da61d90749a6d2d3ee3eea96f00b42dde7 |
| hovercard-subject-tag | issue:2189329618 |
| 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/21347/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2086a0676eb541feeb3ee4105aea19e35a82ef12df648c937fff3f29d273cd64/PowerShell/PowerShell/issues/21347 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2086a0676eb541feeb3ee4105aea19e35a82ef12df648c937fff3f29d273cd64/PowerShell/PowerShell/issues/21347 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | BujuArena |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| 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 | 8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width