Recursively set file attributes
powershell
Solution
It happens because:
Get-ChildItem $targetConfig -Recurse
Return both DirectoryInfo and FileInfo. And Set-ItemProperty fails on setting "ReadOnly" for DirectoryInfo.
To handle this use:
Get-ChildItem $targetConfig -Recurse |
Where-Object {$_.GetType().ToString() -eq "System.IO.FileInfo"} |
Set-ItemProperty -Name IsReadOnly -Value $false
Problem
This code: ``` Get-ChildItem $targetConfig -Recurse | Set-ItemProperty -Name IsReadOnly -Value $false ``` Returns several errors: Set-ItemProperty : Property System.Boolean IsReadOnly=False does not exist. At line:1 char:56 + Get-ChildItem $targetConfig -Recurse | Set-ItemProperty <<<< -Name IsReadOnly -Value $false + CategoryInfo : ReadError: (System.Boolean IsReadOnly=False:PSNoteProperty) [Set-ItemProperty], IOException + FullyQualifiedErrorId : SetPropertyError,Microsoft.PowerShell.Commands.SetItemPropertyCommand What this errors means?