Remove Read Only Attribute on File Using PowerShell

Remove read only property of a file

A common issue that administrators face while restoring files from their backups is that the read-only property of the files comes marked by default. This can cause serious trouble as end users will not be able to edit their documents without duplicating the restored files. However, a simple PowerShell code can be run to remove the read-only attribute of the necessary files.
 
Supplying the file path as a parameter and executing the following code will remove the read only property of a file. 

Script

<#
.SYNOPSIS
This script can be used to remove read only property of a file.
.DESCRIPTION
This script can be used to remove read only property of a file.
.EXAMPLE
C:\PS> C:\Script\To_Remove_Readonlyproperty_of_a_File.ps1 C:\Users\gautam\Desktop\Test_File.ps1
Removes the read only property of Test_File.ps1.
#>
#Set the IsReadonly value to false.

param ( [string]$FileName )
Set-ItemProperty $FileName -name IsReadonly -value $false

 





    • Related Articles

    • How to add/remove Active Directory users to Active Directory groups using PowerShell

      Active Directory is a powerful tool for managing users and groups in a Windows environment. One of the most often-repeated tasks for administrators is to add or remove users from Active Directory groups. In this article, we will explore how to ...
    • Convert a File to a desired naming Format (ASCII, Unicode or UTF8)

      Administrators dealing with a huge number of files know from experience that certain files from applications are not retrieved in a naming format that is compatible with the rest of their workflow. When these files are in the thousands, converting ...
    • Clear Contents of a File

      Temporary files can take up considerable space in a database and eventually slow down computers. Administrators can use the following PowerShell script to completely clear the contents of files remotely. If you want to delete the entire text file ...
    • Create a ShortCut for an Exe File

      Creating a shortcut to an application on multiple end user desktops can be a laborious task. However, the process is pretty straightforward when using a PowerShell script. In the following script, provide the path of the EXE file and the exact path ...
    • Powershell Script to Find and Replace Text in a File

      To find and replace a particular word throughout a file on multiple computers is as laborious as one can imagine. However, with the help of the following PowerShell script, one can easily find a particular word and replace it with a word of choice.   ...