I have a problem with taking ownership of C:\Windows\System32\termsrv.dll.
When I run my script from a elevated powershell prompt :
I got the following error message:
$dir = 'C:\Windows\System32\termsrv.dll'
$domain = $env:USERDNSDOMAIN
$user = $env:USERNAME
#Get current permissions
$ACL = Get-Acl -Path $dir
#Set Owner of file
Set-Acl -Path $dir $ACL
The script is working perfectly if I'm trying to take ownership of a file that is not owned by "TrustedInstaller".
I have to note that i can take ownership by the normal properties->security window.
Anyone that can explain what I'm doing wrong? I would be very thankful