Item properties
The Get-ItemProperty
and Set-ItemProperty
commands allow individual properties to be modified.
Filesystem properties
When working with the filesystem provider, Get-ItemProperty
and Set-ItemProperty
are rarely needed. For example, Set-ItemProperty
might be used to make a file read-only. The following example assumes that the somefile.txt
file already exists:
-
The same property may be directly set from a file object retrieved using Get-Item
(or Get-ChildItem
):
(Get-Item 'somefile.txt').IsReadOnly = $true
The IsReadOnly
flag affects the attributes of the file object, adding the ReadOnly
flag.
Adding and removing file attributes
The attributes property of a file object is a bit field presented as a number and given an easily understandable value by the System.IO.FileAttributes
enumeration.
Note
Bit fields
:A bit-field is a means of exposing multiple settings that have two states (on or off binary states) using a single number...