February 2019
Intermediate to advanced
626 pages
15h 51m
English
Ownership of a file or directory may be changed using the SetOwner method of the ACL object. Changing the ownership of a file requires administrative privileges.
The owner of the C:\Temp\ACL\1 file is the current user:
PS> Get-Acl C:\Temp\ACL\1 | Select-Object OwnerOwner ----- COMPUTER\Chris
The owner may be changed (in this case, to the Administrator account) using the SetOwner method:
$acl = Get-Acl C:\Temp\ACL\1$acl.SetOwner([System.Security.Principal.NTAccount]'Administrator')Set-Acl C:\Temp\ACL\1 -AclObject $acl
Read now
Unlock full access