Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-06-06
7
Medium Priority
?
695 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 1000 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 56

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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

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 56

Accepted Solution

by:
McKnife earned 1000 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

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

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

Here's a look at newsworthy articles and community happenings during the last month.
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

721 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