Make a File Read-Only (and Back) with PowerShell
Toggle the IsReadOnly attribute on any file to lock it from edits or unlock it again.
01Command
$ Set-ItemProperty -Path "C:\Docs\report.xlsx" -Name IsReadOnly -Value $true :: $false to undo02What it does
Every file in NTFS carries an IsReadOnly flag; when it's true, apps that honor the attribute refuse to save over the file. Set-ItemProperty flips it directly, and Get-ItemProperty shows the current state. This is ideal for protecting template or invoice files you keep overwriting by accident.
03Risk
04Undo
$ Set-ItemProperty -Path "C:\Docs\report.xlsx" -Name IsReadOnly -Value $false05Sources
- Set-ItemProperty (Microsoft.PowerShell.Management)Evidence: Documents using Set-ItemProperty with -Path, -Name and -Value to change item property values.
- Set-ItemProperty — Set a property valueEvidence: Lists the IsReadOnly property of files as a value settable via Set-ItemProperty.
Last verified: 2026-09-19 · Category: Files & Folders
06Related solutions
Diagnose NTFS file system errors and bad sectors on any volume — including the system drive while Windows is running — before committing to a repair.
Robocopy is Windows' built-in robust file copier: use /MIR to keep a destination folder as an exact one-way mirror of a source, resumable and restartable.
Search inside text files and logs with regex, returning file, line number and match.