question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bad error message when using Get-Content with a Directory

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
SteveL-MSFTcommented, Oct 8, 2017

@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

1reaction
SteveL-MSFTcommented, Nov 16, 2016

@kedziorm agree that the error message isn’t a good one.

> cat ./Downloads/
/bin/cat: ./Downloads/: Is a directory

Updated title to reflect this discussion

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get-Content : Cannot find path
It says that it cannot find the path because it does not exist and then displays the full (valid) path obtained from Get-ChildItem...
Read more >
powershell - .ps1: Get-Content "Cannot find Path " ... " error
I just worked on other stuff. But since today, I get an error: "Get-Content : Cannot find path 'C:\Users\dohuegadmin\desktop\script\True' ...
Read more >
Callout loop not allowed error when using getContent and ...
The only solution that I can find so far is not to use REST but to replace the getContent() (ie a call to...
Read more >
Too many nested getContent calls error on button click to ...
The issue I'm having: "Too many nested getContent calls" - infinite loop? My VisualForce Code: <apex:page action="{!attachPDF}" extensions= ...
Read more >
Guzzle Error Message gets truncated
I am using a try/catch already - but strange, for both Exception and the \GuzzleHttp\Exception\ClientException there is no getBody() method. I have setup...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found