Bad error message when using Get-Content with a Directory
See original GitHub issueI just installed the latest release of the Powershell by typing:
sudo dpkg -i powershell_6.0.0-alpha.12-1ubuntu1.16.04.1_amd64.deb
There was no errors during installation, but it seems that I have no access to Linux paths from Powershell (even as a root).
Steps to reproduce
Run powershell and type:
Get-Content ~
Expected behavior
Should provide content of the home directory of current user (similarly as Linux command ls ~
).
Please note that even if I run powershell as root (by typing sudo powershell
) I receive mentioned error.
Actual behavior
“PermissionDenied” error
powershell
PS /home/testingdata> Get-Content ~
Get-Content : Access to the path '/home/testingdata' is denied.
At line:1 char:1
+ Get-Content ~
+ ~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (/home/testingdata:String) [Ge
t-Content], UnauthorizedAccessException
+ FullyQualifiedErrorId : GetContentReaderUnauthorizedAccessError,Microsof
t.PowerShell.Commands.GetContentCommand
PS /home/testingdata> whoami
testingdata
PS /home/testingdata>
Trying as a root:
sudo su
cd ~
PS /root> Get-Content ~
Get-Content : Access to the path '/root' is denied.
At line:1 char:1
+ Get-Content ~
+ ~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (/root:String) [Get-Content],
UnauthorizedAccessException
+ FullyQualifiedErrorId : GetContentReaderUnauthorizedAccessError,Microsof
t.PowerShell.Commands.GetContentCommand
PS /root> whoami
root
Environment data
I use Ubuntu 16.04 LTS 64-bit.
Name Value
PSVersion 6.0.0-alpha
PSEdition Core
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
BuildVersion 3.0.0.0
GitCommitId v6.0.0-alpha.12
CLRVersion
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (6 by maintainers)
@iSazonov that’s an interesting idea and makes sense to me as an improvement, but since it’s a
break change
, let’s have Committee review the idea@kedziorm agree that the error message isn’t a good one.
Updated title to reflect this discussion