?
Solved

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

Posted on 2014-03-28
4
Medium Priority
?
271 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
This article describes how to set permissions to allow a limited-permissions user to start and stop a particular System Service.   It is always best to give users only the permissions that they need to perform their job, so tweaking particular permi…
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…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…

765 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