Samstag, August 06, 2011

change NTFS file owner

Changing the owner of a NTFS file with set-acl failed with the errro "Set-Acl : The security identifier is not allowed to be the owner of this object". Found the explanation here. The reason in my case was that I tried to set the user myself, but the owner was the admin.

I was able to do the change with the explorer. But this works only for a single file. If more than one file is selected the contect menue to change the security is not available.

There are some older tools like xcacl but this should only be used with older Windows version (2000 and before). There are also some newer tools for this, but not from Microsoft.

The solution for me was to add read access for all local user. I changed the ACL of one file with the explorer to the desired owns and used the following powershell command to set the ACL to all other files.

ls file[1234] | foreach { get-acl ..\fileWithGoodAcl | Set-Acl $_ }