基于文件夹权限的DFS查看异常AD组

时间:2020-05-14 19:54:42

标签: powershell

尝试使用脚本在DFS中将一长列文件夹设置为“显式视图”。我尝试使用DFSUtil。这是该过程的第三步。

步骤1-根据文件夹名称创建新的AD组,以在此步骤中专门使用。 步骤2-根据当前文件夹权限向新的AD组添加权限 步骤3-这应该将DFS设置为“显式视图”,以便用户只能看到他们有权访问的文件夹。

    $folderlist = get-childitem -Path "C:\depts"
    $folderlist

    foreach ($folder in $folderlist) {
        $name = $folder.FullName.TrimStart("C:\depts\")
        $ACLLIST = Get-ACL $folder.FullName
        $DFSroot = "\\nsstestdc1\Depts\$name"
        $DFSuser = "ITSTEST\Share-$name-RR"
        $DFSpriv = "R"
        Start-Process -FilePath "C:\Windows\system32\dfsutil.exe" -ArgumentList "property SD grant $DFSroot $DFSuser`:$DFSpriv protect"
}

现在,当我运行第3步时,一个屏幕弹出并关闭得如此之快,以至于我看不到是否有任何错误。我正在尝试使用此代码手动运行

    $DFSroot = "\\nsstestdc1\Depts\Group 1"
    $DFSuser = "ITSTEST\Share-Group 1-RR"
    $DFSpriv = "R"
    dfsutil property SD grant $DFSroot $DFSuser`:$DFSpriv protect

我认为我收到的错误是Could not complete the command successfully. SYSTEM ERROR - Element not found.

任何帮助将不胜感激。预先感谢。

1 个答案:

答案 0 :(得分:1)

dfsutil.exe link add '\\Domain\public\Share1' '\\Server\Share1'
dfsutil.exe Property ACL Control '\\Domain\public\Share1' Protect
dfsutil.exe Property ACL Grant '\\Domain\public\Share1' 'Domain\Domain Admins:F'
dfsutil.exe Property ACL Grant '\\Domain\public\Share1' 'Domain\Server-share1 group Local:R'