Attributes
R Read-only
A Archive
S System
H Hidden
attrib +R <file>
Add read-only attribute
attrib -H <file>
Remove hidden attribute
attrib +H +S <file>
Set as Hidden and System attributes
attrib +h *.txt
Hide all .txt files
Add read-only:
Set-ItemProperty <file> -Name Attributes -Value ([System.IO.FileAttributes]::ReadOnly)Remove read-only:
$attributes = (Get-Item <Path\FileName>).Attributes -band (-bnot [System.IO.FileAttributes]::ReadOnly)Set-ItemProperty <Path\FileName> -Name Attributes -Value $attributesAdd multple attributes:
$attributes = (Get-Item <Path\FileName>).Attributes -bor [System.IO.FileAttributes]::Hidden -bor [System.IO.FileAttributes]::SystemSet-ItemProperty <Path\FileName> -Name Attributes -Value $attributesLast updated
Was this helpful?