How can I remove the ReadOnly attribute on a file, using a PowerShell (version 1.0) script?
$file = Get-Item "C:\Temp\Test.txt"
if ($file.attributes -band [system.IO.FileAttributes]::ReadOnly)
{
$file.attributes = $file.attributes -bxor [system.IO.FileAttributes]::ReadOnly
}
The above code snippet is taken from this article
UPDATE Using Keith Hill's implementation from the comments (I have tested this, and it does work), this becomes:
$file = Get-Item "C:\Temp\Test.txt"
if ($file.IsReadOnly -eq $true)
{
$file.IsReadOnly = $false
}