PowerShell: Set File Read Only Attribute

By Xah Lee. Date: .

Show Read Only Status

Get-ItemProperty -Path "~/xtest.txt" -Name IsReadOnly

# IsReadOnly   : False
# PSPath       : Microsoft.PowerShell.Core\FileSystem::C:\Users\xah\xtest.txt
# PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\Users\xah
# PSChildName  : xtest.txt
# PSDrive      : C
# PSProvider   : Microsoft.PowerShell.Core\FileSystem

Set to Read Only

Set-ItemProperty -Path "~/xtest.txt" -Name IsReadOnly -Value $true

Remove Read Only

Set-ItemProperty -Path "~/xtest.txt" -Name IsReadOnly -Value $false

PowerShell. File Properties, Attributes, Permission