Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Set permissions by file name/Inherit Ownership MS Server 2008

Posted on 2012-04-10
6
Medium Priority
?
313 Views
Last Modified: 2012-08-25
Kind of a two part question here. Need to find a way to :

1.) set permissions on folders based on folder name. Scenario - I have hundreds of site based folders, and inside of each one of these folders are four folders, each with the same name

Example

Sites -

   -Site 1
        -Folder A
        -Folder B
        -Folder C
   -Site 2
        -Folder A
        -Folder B
        -Folder C
 and so on.

   I'm trying to find a way to set a permission on every folder under 'sites' named 'Folder A'. I've tried using an XCacl VbScript, but it errors out. Wondering if I am running into ownership issues, as folders are created by different people, which leads to

2) Does anyone know of a way to do a bulk change of folder ownership, so I can set ownership on a parent folder and have all child folders inherit the ownership? I know the chown command works for linux, but havent been able to find anything for MS.
0
Comment
Question by:MRowan75
[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
  • 4
  • 2
6 Comments
 
LVL 10

Expert Comment

by:George Khairallah
ID: 37829184
0
 
LVL 10

Expert Comment

by:George Khairallah
ID: 37829196
This is a quick script that I usually use to fix permissions on user folders (it's written in Kix, can be easily converted to VB). You would have to modify it to fit your folder structure, but it should put you on the right track.

Break ON
; 
; Change this to the base path where your directory is. so, in this case, the user folders would be here: d:\students\%USERNAME%
Global $BasePath $BasePath = 'D:\Students' 
; Replace this with your NetBIOS domain name. (This is used for domain\user notation) 
Global $Domain $Domain = 'YOUROMDAIN'
;-------------------------------------------------------------------

Dim $fh $fh = FreeFileHandle
$ = Open($fh, @SCRIPTDIR + "\users.txt")

$UserName = ReadLine($fh)
Do
	Trim($UserName)
	Shell '%COMSPEC% /c icacls ' + $BasePath + '\' + $UserName + ' /t /c /l /grant ' + $Domain + '\' + $UserName + ':(OI)(CI)F'
	Shell '%COMSPEC% /c icacls ' + $BasePath + '\' + $UserName + ' /setowner ' + $Domain + '\' + $UserName
	$UserName = ReadLine($fh)
Until @ERROR = -1
$ = Close($fh)

Open in new window

0
 
LVL 1

Author Comment

by:MRowan75
ID: 37833719
Thanks. I was able to use icacls to set ownership on all files. Still dealing with the issue of trying to set permissions on all folders named 'settings', as opposed to drilling down to each individual folder. For example,

C:\Sites\Site1\Settings
C:\Sites\Site2\Settings
C:\Sites\Site3\Settings ect.

I have about 700 'site#' folders, and need to edit permissions on every "site#\settings folder". Is there a command or tool that will find all folders named 'settings' within the Sites top level to allow me to do this without manually typing the command 700 times? I'm getting the impression there isn't and I have a long day/week of typing ahead of me...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:George Khairallah
ID: 37833833
are the Site# all under C:\Sites?
You just want to be able to go through the folder C:\Sites\SiteX through C:\Sites\SitesY and change the permissions on the "Settings" folder in each of them?
0
 
LVL 1

Author Comment

by:MRowan75
ID: 37833848
Yes, that is what I am looking for.
0
 
LVL 10

Accepted Solution

by:
George Khairallah earned 1500 total points
ID: 37833921
So I'm not exactly sure of what you're looking to do, but I changed the code so that you can iterate through 700 Site folders, and you can then change whatever you need on each of them. You can run the script as is to see what directories will be targeted. (I commented out the icacls part).

BREAK ON
for $i = 1 to 700
;
; Change this to the base path where your directory is. so, in this case, the user folders would be here: d:\students\%USERNAME%
Global $BasePath $BasePath = 'C:\Site' + $i  
; Replace this with your NetBIOS domain name. (This is used for domain\user notation)
Global $Domain $Domain = 'YOUROMDAIN'
;-------------------------------------------------------------------

;Dim $fh $fh = FreeFileHandle
;$ = Open($fh, @SCRIPTDIR + "\users.txt")
;$UserName = ReadLine($fh)
    ? "DEBUG: Processing: " + $BasePath + '\Settings'
    Trim($UserName)
    ;Shell '%COMSPEC% /c icacls ' + $BasePath + '\Settings' + ' /t /c /l /grant ' + $Domain + '\' + $UserName + ':(OI)(CI)F'
    ;Shell '%COMSPEC% /c icacls ' + $BasePath + '\' + $UserName + ' /setowner ' + $Domain + '\' + $UserName
    $UserName = ReadLine($fh)
;$ = Close($fh)
Next 

Open in new window

0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. 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

I had a question today where the user wanted to know how to delete an SSL Certificate, so I thought that I would quickly add this How to! Article for your reference. WHY WOULD YOU WANT TO DELETE A CERTIFICATE? 1. If an incorrect certificate was …
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 steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
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…

596 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