By accident, I recently tried running Get-Content
on a directory. I'd initially thought it was a file because it was named very similarly to a common file I'd expected to be in the location. So I was further confused when I was given an "Access Denied" error in a location where I should have full control.
Of course, I eventually realized my mistake. Once I actually pointed Get-Content
at some files in the same area, or in subfolders of that path, it worked fine. But the error still strikes me as odd. At the very least, I figure it would be more user-friendly and sensible to present an error that actually says (albeit more politely) "That's not a file you're trying to look at, genius!".
Why does "Access Denied" make sense in this context?
notepad SomeDirectory
and you will get same error.