I have tried many code but still I am not able to remove read-only property of that particular folder.
Below is the code which removes read-only property of the files present under that folder but does not remove read-only attribute of that Folder :
$Path = "C:\Suraj\powershell scripts\review script"
$Files = Get-ChildItem $Path -Recurse
ForEach ($File in $Files) {
Write-Host file:$File IsReadOnly: $File.IsReadOnly
if ($File.Attributes -ne "Directory" -and $File.Attributes -ne "Directory, Archive") {
try {
Set-ItemProperty -Path $Path"\"$File -name IsReadOnly -value $false
}
catch {
Write-Host "Error at file " $Path "\" $File
}
}
}