0

Powershells Get-Childitem is displaying a folder that does not exist (anymore). Windows Explorer does not show the folder when looking at the parent folder. The search tool "Everything" from voidtools still finds the folder.

The folder is not hidden nor a system directory. It is a temporary folder with a timestamp in the name, created years ago. The filename does not include illegal characters, only alphanumeric and dashes.

Get-Childitem shows the folder as ReadOnly.

When I open the folder in Windows, another subdirectory of the parent directory is opened. It could be that I renamed the folder Get-Childitem sees years ago to this one I see when I open it, but I don't know for sure.

Why is that?

OS is Win10 Pro 1909.

sinned
  • 489
  • 6
  • 20
  • I've never seen anything like this in my years with PS, and I tried to repro it an could not thus far. So, this is obviously environmental. So, use other tools to see if it is visible, like Get-Acl, icacls, etc. PowerShell does nothing to supplant/subvert Windows proper, so, if it is showing, that info is being provided from Windows. Try using Move-Item on this target or Get-Member of the target. Now, these are just all a few things to see if other commands or tools expose more details. – postanote Apr 30 '20 at 18:40
  • The fact that both Powershell and Search Everything find the folder means that it still exists, but only Explorer does not show it anymore. It is possible that you deleted the folder using explorer, it removed it from memory, but cached the actual removal until next reboot. Other tools that don't rely on explorer's mechanism still show it, until you reboot. So... have you rebooted? – LPChip Apr 30 '20 at 19:10
  • @LPChip according to the timestamp, I created (and probably deleted or renamed) the folder years ago. So yes, I have rebooted. At least once. – sinned Apr 30 '20 at 19:42

2 Answers2

1

I bet if you remove the Read-only attribute from the folder via PowerShell, it will appear in Explorer.

From the parent folder: (gi <FolderName>).Attributes -= 'ReadOnly'

From within the folder: (gi .).Attributes -= 'ReadOnly'

I also bet that inside the folder is a desktop.ini file. It may have both Hidden & System attributes set, so be sure you're showing SuperHidden filse as well as Hidden:

enter image description here

or from PowerShell: gci *.ini -force

and when you view the contents in Notepad, you'll see a line:

LocalizedResourceName=<Name of subfolder that appears in **Explorer**, but not in **PowerShell** `gci`>

It's a feature that allows system folders to display in a user's preferred language while the filesytem name is unchanged.

Keith Miller
  • 8,704
  • 1
  • 15
  • 28
0

I found out that this is my issue:

Folders renamed through Windows Explorer keep the original name

When I renamed the folder initially, windows decided not to rename it, but to put a desktop.ini file inside the folder with a LocalizedResourceName. So the folder is only shown to have the new name, but does not really have it. Now I google how I can turn this stuff off...

sinned
  • 489
  • 6
  • 20
  • 1
    That's what I explained two days ago!!! – Keith Miller May 02 '20 at 22:29
  • 1
    Did you not see my answer or not understand it? If you don't understand a reply, ask for clarification, don't ignore it! That's just rude. – Keith Miller May 02 '20 at 22:33
  • @KeithMiller I'm sorry, I guess my internet bullshit detector miscategorized your answer because it could make no connection between the question and the readonly attribute mangling. Also, the PS Commands don't work if the folder does not exist under that name. However, it made me consider the desktop.ini file through which I unnecessarily found the answer elsewhere. Take my upvote. – sinned May 03 '20 at 09:48
  • You see my reputation points & think "bullshit"? If you tried the PS command using the display name you were seeing in Exploer, of course it woulodn't work. But if you used the name you were seeing in the PowerShell `gci`, it would. Or perhalps it had special characters & required the -`LiteralPath` parameter. Again, if you don't understand something or an error is thrown, **ASK!** – Keith Miller May 03 '20 at 16:34
  • I still don't get what the readonly attribute has to do with it. I would have wished for the actual hint (desktop.ini with LocalizedResourceName) was in the first or second paragraph of your answer and not somewhere down below – sinned May 03 '20 at 18:01
  • Explorer only processes the desktop.ini file if the folder has its ReadOnly or System attribute set. It was clear you knew how to view the folder PowerShell, so that seemed "quicker" than verifying you understood that there are two layers of hiding files in Explorer. My answer is not that long -- this is a techncal forum, not Twitter. – Keith Miller May 03 '20 at 18:31