Powershell - 查找文件夹权限并展开论坛成员

时间:2016-05-26 15:24:42

标签: excel powershell permissions ntfs

我目前有一个脚本可以获取文件夹及其中所有文件夹(递归)的权限,脚本如下所示。

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

$RootPath = "\\Fileshare\Folder"

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

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

这部分剧本很好。我想继续让脚本抓住文件夹权限中列出的任何组的成员,然后抓取组中的成员,在列出的每个组中创建另一个Excel表。工作表将是该组的名称,该工作表内部将是该组内的成员。

有人会对如何做到这一点有任何指示吗?

提前致谢。

SG

1 个答案:

答案 0 :(得分:1)

作为一般指示:

  1. 要获取有关域的组的成员信息,您需要使用Active Directory模块,或使用ADSI adpater进行查询。
  2. 然后还考虑你可以打一个本地操作系统组,可以使用像`net localgroup'这样的东西。 Examples here for PowerShell.
相关问题