0

我对在 powershell 中使用 get-acl 并将其导出到文件的脚本有疑问。我想要做的是从文件服务器中导出所有具有 isinherited 标志 Flase 的权限。这部分工作完美,但我只允许或拒绝这些文件夹上的类型。我需要知道给定文件夹的确切权限。该用户是否允许读取或写入、执行等。这是我所做的全部代码:

$OutFile = "C:\install\powershell\Permissions.txt"
$Header = "Folder Path,IdentityReference,AccessControlType,IsInherited,InheritanceFlags,PropagationFlags"
Del $OutFile
Add-Content -Value $Header -Path $OutFile 

$RootPath = "C:\install\powershell\"

$Folders = dir $RootPath -recurse | where {$_.psiscontainer -eq $true}

foreach ($Folder in $Folders){ 
$ACLs = get-acl $Folder.fullname | ForEach-Object { $_.Access } 
Foreach ($ACL in $ACLs){ 
if ($ACL.IsInherited -eq $false){ 
$OutInfo = $Folder.Fullname + "," + $ACL.IdentityReference + "," + $ACL.AccessControlType + "," + $ACL.IsInherited + "," + $ACL.InheritanceFlags + "," + $ACL.PropagationFlags 
Add-Content -Value $OutInfo -Path $OutFile 
}}}

所以我的问题是:如何添加 $ACL。获得确切的权限级别。甚至可能吗?我怎样才能得到某种对象列表,我可以使用解析 ACLs? I对不起,如果我解释错了我的问题或者它已经得到了回答,但是因为今天是我使用 powershell 的第一天,我可能不知道如何正确搜索答案.

此致。

UPD:看来我可以尝试使用 $ACL.FileSystemRights 如果它给了我想要的东西,我会更新这篇文章。UPD2:是的,看来我必须在 $Header 中添加 FileSystemRights 并在 $OutInfo 中添加“ + $ACL.FileSystemRights + ” 抱歉打扰!但也许这会帮助某人得到他们需要的东西!:)

4

1 回答 1

0

正在寻求将递归设置到一定的深度。找到了解决方案:不要使用-recurse,而是使用“*”。2 级深:“**”等等。来源: http: //powershell.com/cs/forums/p/11663/25754.aspx

谢谢。

于 2015-01-13T14:18:36.533 回答