Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-03-28
4
Medium Priority
?
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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 1000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

In a hurry?.. scroll down to "HERE's HOW TO DO IT" Section. Greetings All, I was going to post this as question/solution, but its seems more appropriate as an article considering its length.  I felt it important to illucidate all the details c…
Log files are useful in diagnosing and repairing problems.  This is a list of common log files and their standard locations that I've compiled.   While this is not exhaustive, it is a pretty good list that I've found to be useful.  I may update it f…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
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…

610 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