Setting file ownership in PowerShell · Tue Jan 8, 10:24 PM
My latest target of investigations — Windows PowerShell — is pretty spiffy. Today I learned one way (I’m sure there are easier ways) to set the owner for a directory’s files to the “Administrators” group, to wit:
$fix = (Get-ChildItem | Get-Acl | ?{ $_.Owner -ne ‘BUILTIN\Administrators’ })
$acct = New-Object System.Security.Principal.NTAccount(“Administrators”)
foreach ($f in $fix) { $f.SetOwner($acct); (Get-Item $f.Path).SetAccessControl($f); }
-- David --
...
Hello out there! No, I'm not dead. WARNING: Future content may violate your expectations!
Archive by Date
Articles By Category:
- Administrative (51)
- Art (3)
- Books (14)
- Business (1)
- Clocks (8)
- Dating (1)
- Events (7)
- Flickr (1)
- Fonts (8)
- Human-Nature (1)
- Humor (5)
- Military (4)
- Misc (121)
- Movies (5)
- Music (68)
- OLE-DB (1)
- Poetry (4)
- Quotes (5)
- Relationships (1)
- Security (1)
- Shoes (2)
- Software (115)
- Spirits (11)
- Surveys (1)
- Tequila (6)
- Virtualization (9)
- Web (9)
- Website (20)
- Wood-Related (2)
- Writing (7)

