将"Everyone"组添加到目录及其所有子目录中

tem*_*pid 7 windows security powershell usergroups

我目前正在使用Vista 32位.如何添加Windows安全组"Everyone"并完全控制目录及其所有子目录和所有文件?是否有我可以使用的powershell脚本?

谢谢!

tem*_*pid 10

我扩展了martona的代码片段,并能够访问所有文件夹和子文件夹.这是我的代码 -

$FilesAndFolders = gci "c:\data" -recurse | % {$_.FullName}
foreach($FileAndFolder in $FilesAndFolders)
{
    #using get-item instead because some of the folders have '[' or ']' character and Powershell throws exception trying to do a get-acl or set-acl on them.
    $item = gi -literalpath $FileAndFolder 
    $acl = $item.GetAccessControl() 
    $permission = "Everyone","FullControl","Allow"
    $rule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
    $acl.SetAccessRule($rule)
    $item.SetAccessControl($acl)
}
Run Code Online (Sandbox Code Playgroud)


Kei*_*ill 6

有时,“本机”PowerShell 方式不一定是最好的方式。对于这样的事情,我仍然会使用 icacls.exe。请记住,好的 ol' exe 在 PowerShell 中运行良好。只需 cd 到您要设置的目录并执行:

icacls $pwd /grant "Everyone":(OI)(CI)F
Run Code Online (Sandbox Code Playgroud)

这将使每个人都可以向下访问当前目录(通过权限继承)。只要 dir 结构中没有对 Everyone 的明确拒绝,这应该有效。


mar*_*ona 5

$acl = Get-Acl c:\mydir
$permission = "Everyone","FullControl","Allow"
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($rule)
$acl | Set-Acl c:\mydir
Run Code Online (Sandbox Code Playgroud)