PowerShell: Set File Attributes

By Xah Lee. Date: .

Set Attributes to a File/Dir

# set attributes to a dir, make it ReadOnly

(Get-Item "~/Downloads/xxt").Attributes = "Directory", "ReadOnly"
# set attribute of a dir, make it just Directory and remove all others such as ReadOnly
(Get-Item "~/Downloads/xxt").Attributes = "Directory"
pwsh get set attributes 2022-02-18 GT2W
pwsh get set attributes

PowerShell: File Attributes