Tip: You can check, set or remove the ReadOnly attribute of a file:
1 2 3 4 5 6 7 8 9 10 |
$file = 'C:\demo\demo.txt' # Check (Get-ChildItem -Path $file).IsReadOnly # Set Set-ItemProperty -Path $file -Name IsReadOnly -Value $true # Remove Set-ItemProperty -Path $file -Name IsReadOnly -Value $false |
Note: You can also use the FileInfo class that way: ([System.IO.FileInfo]'C:\demo\demo.txt').IsReadOnly