Get-Item ./.hidden-file fails with "Could not find item"
See original GitHub issueThis behavior is on macOS 11.3.
Steps to reproduce
> Get-Item ~/.profile
Expected behavior
Directory: /Users/nimazzuc
Mode LastWriteTime Length Name
---- ------------- ------ ----
----- 4/28/2021 12:25 PM 107 .profile
Actual behavior
Get-Item: Could not find item /Users/nimazzuc/.profile.
Environment data
WSManStackVersion = 3.0
PSEdition = Core
Platform = Unix
PSCompatibleVersions = 1.0 2.0 3.0 4.0 5.0 5.1.10032.0 6.0.0 6.1.0 6.2.0 7.0.0 7.1.3
GitCommitId = 7.1.3
OS = Darwin 20.4.0 Darwin Kernel Version 20.4.0: Fri Mar 5 01:14:02 PST 2021; root:xnu-7195.101.1~3/RELEASE_ARM64_T8101
PSRemotingProtocolVersion = 2.3
SerializationVersion = 1.1.0.1
PSVersion = 7.1.3
Additionally, the Mode
thing is weird, shouldn’t that show the unix file mode?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:17 (4 by maintainers)
Top Results From Across the Web
6 Ways to Fix the “Could Not Find This Item” Deletion Error ...
1. Restart Windows Explorer · Right-click Start on the Taskbar and select Task Manager. · In the Processes tab, select Windows Explorer and...
Read more >Powershell Get-Item not working on some directories like ...
The AppData directory has the hidden attribute set: PS C:\> attrib $env:USERPROFILE\AppData H C:\Users\username\AppData.
Read more >Could not find this item while deleting a folder.
I tried refreshing file explorer, used command prompt (it says system cannot find the path specified though I directly copied the path from ......
Read more >Fix “Could Not Find This Item” When Deleting in Windows
The message reads “could not find this item” and it prevents you from deleting the file. It's pretty obvious you're trying to delete...
Read more >Unable to compress hidden files with Compress-Archive #66
Get-Item : Could not find item C:\Compress-Archive test\Input\2.txt. At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is… very weird to me, but fair enough. I still think it’s a bug (or at least a thing that should be changed), since hidden files aren’t “different” from regular files on unices.
Yeah, the fact that
Get-Item
requires-Force
to “find” a hidden file just means that one should always pass-Force
toGet-Item
, since:this is entirely reasonable code to write; additionally:
is also entirely reasonable code to write. There is no reason that putting these two bits of code together should fail, assuming
.config.json
exists, yet the default is that it does fail with a File Not Found error (which is… a very odd error, I must say).EDIT: I would also argue that the behavior makes no sense on Windows either; why does
Get-Item ~/AppData
fail. That is very, very weird behavior.