Skip to content

Bad error message when using Get-Content with a Directory #2686

@kedziorm

Description

@kedziorm

I 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Committee-ReviewedPS-Committee has reviewed this and made a decisionResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions