Change owner recursively with Powershell?
- by Mikael Grönfelt
I'm trying to use Powershell to change owner of a folder, recursively.
I'm basically using this code:
$acct1 = New-Object System.Security.Principal.NTAccount('DOMAIN\Enterprise Admins')
$profilefolder = Get-Item MyFolder
$acl1 = $profilefolder.GetAccessControl()
$acl1.SetOwner($acct1)
set-acl -aclobject $acl1 -path MyFolder
This will change ownership at the first level, but not for any subfolders or files. Is there a way to extend the scope to all content of MyFolder?