PowerShell: Set a File's Attributes

By Xah Lee. Date: . Last updated: .

Set a Directory's Attributes

# set a dir's attributes to, make it ReadOnly

(Get-Item "~/Downloads/xtest").Attributes = "Directory", "ReadOnly"
# set a dir's attribute, make it just Directory and remove all others such as ReadOnly
(Get-Item "~/Downloads/xtest").Attributes = "Directory"

PowerShell. File Properties, Attributes, Permission