Remove Readonly Attribute from All Files in a Folder using PowerShell

When working with content copied from an ISO file, like the Hydration Kit ISO, you'll find that the files are being marked as read only after being copied from the ISO to a folder. Like the CustomSettings_DC01.ini shown in the below example.

File marked as read only.

The Script

To remove the Readonly attribute on all the files, you can use a bit of PowerShell. Please note that this example is just one of many ways in PowerShell to change file attributes. But this worked great for my needs.

Note: In the below example I'm using the -File parameter for the Get-ChildItem cmdlet to get only files (you can't set read only on a folder), and the -Force to get files that may be marked as hidden.

# Script to remove the read only attribute of all files in folder
$Folder = "D:\HydrationCMWS2019-DN\ISO"

# Get all files (not folders) in the target folder
Get-ChildItem $Folder -Recurse -File -Force | foreach { Set-ItemProperty -Path $_.FullName -Name IsReadOnly -Value $false }
About the author

Johan Arwidmark

0 0 votes
Article Rating
Subscribe
Notify of
guest
4 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Steve
Steve
7 months ago

Thanks for the tips. I needed to remove some specific files from an extracted archive, and luckily all of the files I needed removed (multiple copies) had the same names. I followed your example and condensed it for my specific needs:

$x = @(gci -recurse -filter "xxx.txt")
$x += @(gci -recurse -filter "yyy.txt")
$x | Set-ItemProperty -Name IsReadOnly -Value $false
$x | Remove-Item

bob
bob
7 months ago

This is when someone says laughs in cmd


>