Solved

Windows File Server - Get Access to all Files on NTFS Share

Posted on 2014-03-28
4
267 Views
Last Modified: 2014-03-28
I have a Windows 2012 Filecluster.  As I am during a fileserver migration, I need to delete all files and folders from the department share.  Although I am domain admin, I don't have access to all folders / files.

I can take ownership manually and grant myself access to the files.  As there is a large amount of files, I would like to run this automated e.g. using a batch or powershell.

How can I get access to all files on my fileshare?

Thanks!
0
Comment
Question by:whenz
  • 2
4 Comments
 
LVL 25

Expert Comment

by:Tony Giangreco
ID: 39961538
Here is the powershell command to delete all files in a folder

Remove-Item c:\folder_name\*
0
 
LVL 13

Assisted Solution

by:Santosh Gupta
Santosh Gupta earned 250 total points
ID: 39961540
Hi,

Try this to take ownership, you can change your path (currently d:\), run it as command and leave it.

forfiles /p d:\ /s /m *.* /c "cmd /c takeown /f @path"
0
 
LVL 15

Accepted Solution

by:
jrhelgeson earned 250 total points
ID: 39961550
I understand that you are taking control of the files in order to delete them.  This is what you need.  These commands will take ownership, then grant full permissions to Domain Admins - which you can then use to delete the files.

Two commands you need: "Takeown" and "icacls".
takeown.exe /F * /D /A /R
for /D %%I in (*) DO iCACLS.exe "%%I" /T /grant "%USERDNSDOMAIN%\Domain Admins":F /inheritance:e

Open in new window


Browse to the root of the directory that you want to take control over all the sub-folders and files.  Then run those two commands.

From the command prompt, type "Takeown" or "icacls" and you'll see all the command options.
For Takeown, the '/F' specifies the file or folder, which I put as * to specify all files/folders.  '/D' suppresses the confirm prompt, '/A' gives ownership to administrators group rather than current logged in user, and '/R' tells it to recurse the folders and touch all the subfolders.

On the icacls line, you can replace %USERDNSDOMAIN% with your existing DNS domain, i.e. "domain.local\Domain Admins"
0
 
LVL 15

Expert Comment

by:jrhelgeson
ID: 39961572
Alternately, you can create an empty folder on a different drive, then use Robocopy with the "/B" (backup) mode, combined with /PURGE to delete files without having to take ownership of them.

1) Create directory C:\FOO
2) Files to be deleted: D:\OLDDATA\  (all files, folders & subfolders)

Robocopy command:
robocopy C:\FOO D:\OLDDATA /B /PURGE /NOCOPY

Open in new window

The /B runs the command in backup mode, which invokes it as a system process and bypasses file permissions, the /PURGE will delete any files not found in the source.  You may need to specify /E to recurse into sub-folders, but I don't think so.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many times while working on a computer regardless of any Operating System, lag and crashes seem to creep in, hindering your working speed. Sometimes, it can also cause your work to be lost unexpectedly and as a result, you are unable to meet your de…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question