I would like to do the equivalent of chmod -w+r-x foo or attrib +R foo in Windows Powershell. Putzing around, I notice a fairly gnarly Set-Acl function that looks significantly fancier than what I need.
How do I do attrib +R foo in Windows Powershell?
The PowerShell Community Extensions comes with Set-Writable (aliased to swr) and Set-ReadOnly (aliased to sro). I use them both frequently. Removing execute privileges does require a change to the ACLs however using Get-Acl/Set-Acl is painful. I would use icacls.exe.
BTW if you don’t want to mess with any 3rd party stuff, setting readonly to true/false is pretty easy: