权限Powershell脚本的继承

权限Powershell脚本的继承

本文介绍了权限Powershell脚本的继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个将传递子文件夹继承的脚本。

I am trying to create a script that will pass down inheritance of the subfolder.

例如:

C:/template has x y z permissions
C:/template/test only has x permissions

我想要所有子文件夹和文件来自C:/ template获取xyz权限。

I want all sub folders and files from C:/template to get the x y z permissions.

类似于(它没有执行):

Something similar to the script here that Robert Prust made (it does not execute):

$ACL = Get-Acl -Path C:\Template
$Folders = Get-ChildItem -Recurse -Path "C:\new_perm" -Filter 'Subfolder*' | Select-Object -ExpandProperty FullName
foreach ($Folder in $Folders) {
   # write the variables found - check if the folder path is correct
   # Write-Output "This foldername is $Folder"
   # convert foldername to a icacls approved path
   $icacls = "$Folder\*"
   # check if the icacls path is correct
   # Write-Output "icacls path is $icacls"
   #set the ACL required on the folder
   Set-ACL -Path $Folder -AclObject $ACL
   # replace all child permissions for the folder
   icacls $icacls /q /c /t /reset
}

谢谢,

Jonathan

推荐答案

只需运行 icaclsC:\ template \ */ q / c / t / reset 。它并不简单。

Just run icacls "C:\template\*" /q /c /t /reset. It doesn't get simpler than that.

这篇关于权限Powershell脚本的继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 15:07