Server 2012 – taking ownership of files

Windows

I recently had issues where taking ownership of files through the GUI simply failed every time, despite indicating that it had been successful.

A bit of ‘Googling’ led me to an article on Microsoft’s website.

Launch Powershell as Administrator (if not logged in as Administrator)
Change the the drive containing the files / folders you want to assume ownership of.

takeown /F e:\myfolder

If you want to recurse through the folder, then pass the ‘/R’ option:

takeown /R /F e:\myfolder

Once you have taken ownership, you can then set permissions with ICACLS:
This will grant permissions to the Administrators group.

ICACLS e:\myfolder\*.* /grant administrators:F

This will grant permissions to the Administrator user only.

ICACLS e:\myfolder\*.* /grant administrator:F

NOTE: To recurse through all sub folders, you need to run:

icacls "e:\myfolder\*" /q /c /t /reset

You should now have ownership of all folders / files within e:\myfolder

If you are still having problems copying the files, you may be running into UAC issues.

See this post to resolve this.