Change Owner

Take ownership of a file:

takeown /f <file>

Follow these steps in PS:

  1. Get a reference to the file:

$file = Get-Item <Path\FileName>
  1. Get the current ACL of the file:

$acl = Get-Acl $file.FullName
  1. Specify the new owner's user account:

$user = "DOMAIN\User"
  1. Create new ACL entry with the new owner:

$acl.SetOwner([System.Security.Principal.NTAccount]$user)
  1. Apply the new ACL to the file:

Set-Acl -Path $file.FullName -AclObject $acl 

Last updated

Was this helpful?