Solved

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

Posted on 2013-06-06
7
679 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 22

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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Remote Apps is a feature in server 2008 which allows users to run applications off Remote Desktop Servers without having to log into them to run the applications.  The user can either have a desktop shortcut installed or go through the web portal to…
Synchronize a new Active Directory domain with an existing Office 365 tenant
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 …

932 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

10 Experts available now in Live!

Get 1:1 Help Now