2014-12-04 64 views
0

我正在寻找一种方式,在那里我使用powersell运行脚本,通过文件夹结构并将某些NTFS权限仅设置为名称为“提交”的文件夹,因此如果有任何文件夹称为“提交”文件夹结构,它会将其设置为我指定的NTFS权限..如何将NTFS权限设置为文件夹结构中的特定文件夹?

任何信息都会帮助我开始!

http://s22.postimg.org/r769bcr01/Capture.png

可以说我有这么多的文件夹,每个文件夹中,该结构是相同的:

http://s15.postimg.org/pqh8leph7/sasa.png

所以我必须努力04_architecture例如,运用一定的NTFS权限,使用PowerShell。

+1

'find'和'cacls'? – 2014-12-04 21:49:45

+3

PowerShell中的“Get-ChildItem”和“Set-ACL”。这是一个非常广泛的问题。 SO并不是一个真正的地方可以作为一个起点。 – Matt 2014-12-04 22:05:02

回答

0

也许这是一个出发点:

# find all submissions directories 
$submissions = Get-ChildItem -Path "YOUR START PATH e.g. c:\test" -Recurse -Filter "Submissions" -directory 
foreach($submission in $submissions) 
{ 
    # get the current submission directory acl 
    $acl = Get-ACL $submission.FullName 

    # create a new acl. Example: 
    $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule('Administrators','FullControl','ContainerInherit, ObjectInherit', 'None', 'Allow') 

    # add and set the new created acl to the directory 
    $acl.AddAccessRule($accessRule) 
    Set-Acl $submission.FullName $acl 
}