{"action":"closed","issue":{"url":"https://api.github.com/repos/PowerShell/PowerShell/issues/7770","repository_url":"https://api.github.com/repos/PowerShell/PowerShell","labels_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/7770/labels{/name}","comments_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/7770/comments","events_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/7770/events","html_url":"https://github.com/PowerShell/PowerShell/issues/7770","id":359626979,"node_id":"MDU6SXNzdWUzNTk2MjY5Nzk=","number":7770,"title":"Get-Content throws confusing error when targeting a container","user":{"login":"vexx32","id":32407840,"node_id":"MDQ6VXNlcjMyNDA3ODQw","avatar_url":"https://avatars3.githubusercontent.com/u/32407840?v=4","gravatar_id":"","url":"https://api.github.com/users/vexx32","html_url":"https://github.com/vexx32","followers_url":"https://api.github.com/users/vexx32/followers","following_url":"https://api.github.com/users/vexx32/following{/other_user}","gists_url":"https://api.github.com/users/vexx32/gists{/gist_id}","starred_url":"https://api.github.com/users/vexx32/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vexx32/subscriptions","organizations_url":"https://api.github.com/users/vexx32/orgs","repos_url":"https://api.github.com/users/vexx32/repos","events_url":"https://api.github.com/users/vexx32/events{/privacy}","received_events_url":"https://api.github.com/users/vexx32/received_events","type":"User","site_admin":false},"labels":[{"id":552752388,"node_id":"MDU6TGFiZWw1NTI3NTIzODg=","url":"https://api.github.com/repos/PowerShell/PowerShell/labels/Area-Cmdlets-Management","name":"Area-Cmdlets-Management","color":"5319e7","default":false},{"id":311043050,"node_id":"MDU6TGFiZWwzMTEwNDMwNTA=","url":"https://api.github.com/repos/PowerShell/PowerShell/labels/Issue-Enhancement","name":"Issue-Enhancement","color":"fc2929","default":false},{"id":311043049,"node_id":"MDU6TGFiZWwzMTEwNDMwNDk=","url":"https://api.github.com/repos/PowerShell/PowerShell/labels/Resolution-Duplicate","name":"Resolution-Duplicate","color":"ffffff","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2018-09-12T19:50:29Z","updated_at":"2018-09-28T15:36:14Z","closed_at":"2018-09-28T15:36:14Z","author_association":"NONE","body":"Rather than either producing a sensible error, or behaving in a reasonably predictable manner, `Get-Content` incorrectly throws an `Access Denied` error when pointed at a container object. This is *also* the case when using the variable accessor syntax.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\nPS> Get-Content c:\\\r\n```\r\nor\r\n```powershell\r\nPS> ${c:\\}\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\nOption #1: A sensible error is produced\r\n```none\r\nGet-Content : Unable to access item contents as it is a container. You may be looking for Get-ChildItem instead.\r\nAt line:1 char:1\r\n+ Get-Content c:\\\r\n+ ~~~~~~~~~~~~~~~\r\n+ CategoryInfo          : ***: (C:\\:String) [Get-Content], ***\r\n+ FullyQualifiedErrorId : ***,Microsoft.PowerShell.Commands.GetContentCommand\r\n```\r\nOption #2: Route the call through to Get-ChildItem instead.\r\nWhat is the \"content\" of a container if not its child items? It would make at least intuitive sense for Get-Content to simply call Get-ChildItem if passed a path to a container object instead of a leaf object.\r\n```none\r\nDirectory: C:\\\r\n\r\n\r\nMode                LastWriteTime         Length Name\r\n----                -------------         ------ ----\r\nd-----       10/20/2017   2:55 PM                msys64\r\nd-----        4/11/2018   7:38 PM                PerfLogs\r\nd-r---        9/11/2018   2:11 PM                Program Files\r\nd-r---        8/27/2018   6:53 AM                Program Files (x86)\r\nd-----       10/17/2017   2:52 PM                tmp\r\nd-r---        5/16/2018   3:10 AM                Users\r\nd-----        11/6/2017   2:57 PM                usr\r\nd-----         9/3/2018   5:02 AM                Windows\r\n```\r\n\r\nActual behavior\r\n---------------\r\n\r\n(Cmdlet access)\r\n```none\r\nGet-Content : Access to the path 'C:\\' is denied.\r\nAt line:1 char:1\r\n+ Get-Content c:\\\r\n+ ~~~~~~~~~~~~~~~\r\n+ CategoryInfo          : PermissionDenied: (C:\\:String) [Get-Content], UnauthorizedAccessException\r\n+ FullyQualifiedErrorId : GetContentReaderUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetContentCommand\r\n```\r\n(Variable access syntax)\r\n```none\r\nAccess to the path 'C:\\' is denied.\r\nAt line:1 char:1\r\n+ ${C:\\}\r\n+ ~~~~~~\r\n+ CategoryInfo          : PermissionDenied: (C:\\:String) [], UnauthorizedAccessException\r\n+ FullyQualifiedErrorId : GetContentReaderUnauthorizedAccessError\r\n```\r\n\r\nEnvironment data\r\n----------------\r\n\r\n<!-- provide the output of $PSVersionTable -->\r\n\r\n```powershell\r\n> $PSVersionTable\r\n\r\nName                           Value\r\n----                           -----\r\nPSVersion                      6.1.0-rc.1\r\nPSEdition                      Core\r\nGitCommitId                    6.1.0-rc.1\r\nOS                             Microsoft Windows 10.0.17134\r\nPlatform                       Win32NT\r\nPSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}\r\nPSRemotingProtocolVersion      2.3\r\nSerializationVersion           1.1.0.1\r\nWSManStackVersion              3.0\r\n```\r\n\r\nIn my opinion, given the fact that the variable access syntax is a bit... edge case at the best of times (although undoubtedly also very handy at times) it would seem to make sense that Get-ChildItem would be called in these cases, so that it's possible to explore a provider in this fashion without necessitating use of the cmdlets at all."}}
{"actor":{"display_login":"iSazonov"}}