Change Owner
Take ownership of a file:
takeown /f <file>
Follow these steps in PS:
Get a reference to the file:
$file = Get-Item <Path\FileName>
Get the current ACL of the file:
$acl = Get-Acl $file.FullName
Specify the new owner's user account:
$user = "DOMAIN\User"
Create new ACL entry with the new owner:
$acl.SetOwner([System.Security.Principal.NTAccount]$user)
Apply the new ACL to the file:
Set-Acl -Path $file.FullName -AclObject $acl
Last updated
Was this helpful?