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?
It happens because:
Return both DirectoryInfo and FileInfo. And Set-ItemProperty fails on setting “ReadOnly” for DirectoryInfo.
To handle this use: