Solved

Script to add AD account to owner of Multiple folders and sub folders

Posted on 2013-06-06
7
692 Views
Last Modified: 2013-07-25
Good Afternoon

I am looking for some advice

I am going through a massive file share but some data i cannot see as users have taken ownership and removed access.

I have noticed that if i take ownership of the folder/file one at a time, then i can add myself backin and not blow away all the other security permissions.

Can this be automated in a batch file/script so that the script goes through each folder and then adds a certain AD account as the owner with full control.  I cannot use the "Replace owner on subcontainers and objects" as i do not want to destroy permissions from sub folders.

I hope this makes sense.

Please let me know if more info is needed.

Mark
0
Comment
Question by:Mark_Mckie
[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
7 Comments
 
LVL 23

Expert Comment

by:yo_bee
ID: 39228878
You can try takeown commands to accomplish this task.
This is a built in command of Windows.

http://technet.microsoft.com/en-us/library/cc753024(v=ws.10).aspx

Run CMD as an Administrator of the Domain or System.

TAKEOWN /F directory /R /A
0
 
LVL 38

Assisted Solution

by:Jim P.
Jim P. earned 250 total points
ID: 39230763
Have you heard of CACLS (Command line Access Control List)?

I'm not great at it but have used a few times to change permissions on files.

Here's the tutorial I use: http://ss64.com/nt/cacls.html
0
 
LVL 55

Expert Comment

by:McKnife
ID: 39233575
Hi.

> I cannot use the "Replace owner on subcontainers and objects" as I do not want to destroy permissions from sub folders.
Why not? It does NOT replace permissions, it replaces the owner. Do it.
[Another tool in addition to takeown is subinacl.exe, it can write other owners as yourself]
0
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 

Author Comment

by:Mark_Mckie
ID: 39234192
Hi McKnife thanks for that, i am using subinacl to add myself as an owner to all directorys and sub directorys and files using the below command

subinacl /subdirectories "\\ari-ds-01\Public\Corporate Services\*.*" /setowner=NFDG\server

do you know what command i would use to then grant the NFDG\server account full control to all all directorys and sub directorys and files whilst keeping current permissions intact?

Thanks so much.
Mark
0
 
LVL 55

Accepted Solution

by:
McKnife earned 250 total points
ID: 39234262
You can use icacls.exe /grant for that.
0
 

Author Closing Comment

by:Mark_Mckie
ID: 39354292
Just what I needed
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

623 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