Taking ownership without removing existing user rights
I have a network share with lots of folders and files with ownership set to different users and explicit denies set against the domain admins group (don`t ask). I need to move the files to a new server, the existing server is a snap server.
I want to run a script to take ownership over every file and modify the existing rights. I have written a batch file (see below). The problem I have is that takeown /d y will strip out the existing rights on some folders.
Is there a way to preserve all existing user rights while taking ownership and adding full access to a certain group?
takeown /f %1 /r /d y
icacls %1 /grant "domain\Domain Admins:F" /t > "C:\Logs\icacls.txt"