Changing File and Folder Ownership

If you want to set an owner for a folder, you need to run the SetOwner method. Let’s make “ENTERPRISE\J.Carter” the owner of the “Sales” folder:

$acl = Get-Acl \\fs1\shared\sales
$object = New-Object System.Security.Principal.Ntaccount("ENTERPRISE\J.Carter")
$acl.SetOwner($object)
$acl | Set-Acl \\fs1\shared\sales

Notice that we again used the Ntaccount class to convert the user account name from a string into a SID.

Note that the SetOwner method does not enable you to change the owner to any account you want; the account must have the “Take Ownership”, “Read” and “Change Permissions” rights.