I mistakenly turned C:\Users\User into a hidden folder. Now, a lot of my programs aren't running. I can't even open file explorer. I managed to open powershell in admin mode, but am able to see the hidden folders using ls - Force. However, I don't know how to unhide them. How to I remove the the hidden attribute so that the mode of the folders change from d--h-- to d-----?
As Lee_Dailey points out, you can edit the Attributes property value on the corresponding DirectoryInfo object.
Since Attributes is a Flags enum (or a bit field if you will), the easiest way to remove a flag is to use bitwise operators:
$folder = Get-Item C:\Users\User -Force
$folder.Attributes = $folder.Attributes -band -bnot [System.IO.FileAttributes]::Hidden
This will set the value of Attributes to whatever it already is, but excluding the Hidden flag regardless of whether it was set or not
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With