【发布时间】:2016-06-19 22:26:53
【问题描述】:
几年前,在我们公司的文件服务器上,我们曾经拥有宽松的权限。 这意味着,有些文件夹的用户往往拥有完全权限。这是一件坏事(用户玩弄权限,锁定系统(和备份)并且只给自己访问权限。
我的目标:
逐个文件夹扫描文件服务器文件夹(文件太多)并输出
- 文件夹完整路径
- 安全身份参考
如果有人除了域管理员或系统之外拥有完全访问权限。
输出会很好:
路径,ACL E:\share\projectfolder, 域\10JohnDoe E:\share\commonfolder, 域\所有人 ...
这是我所拥有的,但还远远不够:
##define variable
$path = "E:\Share"
## begin script
foreach ($file in Get-Childitem $path -Recurse -Directory) {
if (Get-Acl $file.FullName |
select -ExpandProperty Access |
where {$_.IdentityReference -notlike "AT\Domain Admins" -and
$_.IdentityReference -notlike "NT AUTHORITY\SYSTEM" -and
$_.AccessControlType -like "Allow" -and
$_.FileSystemRights -like "FullControl"}
) {
Write-Host $file.FullName >> e:\check_acl.txt
Get-Acl $file.FullName |
select -ExpandProperty Access |
where {$_.IdentityReference -notlike "AT\Domain Admins" -and
$_.IdentityReference -notlike "NT AUTHORITY\SYSTEM" -and
$_.AccessControlType -like "Allow" -and
$_.FileSystemRights -like "FullControl"
} >> e:\check_acl.txt
}
}
但我想,我不能像那样得到输出(到文件中!)。
【问题讨论】:
标签: powershell acl fileserver