This is just “reminder post” for me if I will need to use it in future…
I wanted to create hidden folder using Powershell – in fact, it’s not very hard:
$(MkDir “Martin Zugec”).Attributes = ‘Hidden’
.Attributes is FileAttributes enumeration, so you use same syntax when you want to create files. Below are available values:
Archive | Applications use this attribute to mark file\folder for backup or removal |
Compressed | Is compressed |
Device | N/A – in future maybe ;) Looks promising :) |
Directory | “File is directory” :) |
Encrypted | Encrypted |
Hidden | Hidden |
Normal | If no other attributes are applied |
NotContentIndexed | Skip for indexing |
Offline | File\Folder is offline |
ReadOnly | File\Folder is read-only |
ReparsePoint | Contains reparse point. Reparse point is user data associated with this entry – one example where reparse points are used is when you mount folder into another. |
SparseFile | Sparse files are usually large files whose data are mostly zeros. To be honest, I never saw sparse file as far as I know – even fake huge files (FSUtil File CreateNew) are not sparse files. |
System | System file |
Temporary | If file is marked as temporary, file system will try to keep all the data in memory for quicker access instead of flushing data back to harddisk. Of course temporary file should be deleted as soon as possible if not needed ;) |
If you want to change attribute of existing folder\file, it’s also very easy:
$(Get-Item “Martin Zugec”).Attributes = ‘Hidden’