Solved

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

Posted on 2013-06-06
7
674 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
7 Comments
 
LVL 21

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 53

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
Want to promote your upcoming event?

Attending an event? Speaking at a conference? Or exhibiting at a tradeshow? Easily inform your contacts by using a promotional banner in your email signature. This will ensure your organization’s most important contacts are in the know.

 

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 53

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Installing a printer using group policy preferences is not that hard let’s take a look at it. First lets open up your group policy console and edit the policy you want to add it to. I recommend creating a new policy for each printer makes it a l…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now