Join Us!

Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.
A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Enter the characters shown in the image.


Enter your Project Envision username.
Enter the password that accompanies your username.
Request new password

Remove Read Only Attribute in PowerShell

Removing Read Only attribute is quite common task everyday work. We can always use Windows Explorer to remove Read Only attribute. However sometimes removing Read Only attribute should be just a small part of our script and Windows Explorer method is not an option. Alternatively to PowerShell we could use our good old friend attrib command, but I am PS fan and I would like to share with you how to do it in PowerShell.

Let us assume that I have directory named tmp under My Documents, which contains Assets folders with files from which I want to remove read only attribute. First lets list all files from desired directory with printing out the value of Read Only attribute

PS C:\Users\krystian.zieja\Documents\tmp> foreach($file in (Get-ChildItem .\Assets)) 
>> {
>>     Write-Host $file.Name $file.IsReadOnly
>> }
account.png True
accountProtected.png True
cancel.png True
check.png True
delete.png True
goto.png True
login.png True
loginProtected.png True
new.png True
note.png True
noteProtected.png True
save.png True
settings.png True
wallet.png True
walletProtected.png True

Next using Set-ItemProperty cmdlet we will change the value of IsReadOnly attribute

PS C:\Users\krystian.zieja\Documents\tmp> foreach($file in (Get-ChildItem .\Assets)) 
>> {
>> Set-ItemProperty $file.FullName -Name IsReadOnly -Value $false
>> }

Obviously to above script we could add an if statement which would restrict setting Read Only to false only on files that have that attribute set to true. Like in the following example

PS C:\Users\krystian.zieja\Documents\tmp> foreach($file in ((Get-ChildItem .\Assets) | Where-Object { $_.IsReadOnly -eq $True }))
>> {
>>     Write-Host $file.Name $file.IsReadOnly
>> }

Finally we will confirm that our changes were correctly applied .

PS C:\Users\krystian.zieja\Documents\tmp> foreach($file in (Get-ChildItem .\Assets))
>> {
>>     Write-Host $file.Name $file.IsReadOnly
>> }

account.png False
accountProtected.png False
cancel.png False
check.png False
delete.png False
goto.png False
login.png False
loginProtected.png False
new.png False
note.png False
noteProtected.png False
save.png False
settings.png False
wallet.png False
walletProtected.png False