我是Power
Shell脚本的新手(自从我开始学习powershell以来将近一个月).
我目前正在使用powershell 2.0编写一个脚本来清理文件夹NTFS ACL.我想删除除管理员之外的每个acl.
我的问题是我找不到删除每个非管理员的acl的方法,而不知道它们.
所以我来到这里寻求powershell pro.
此代码删除acl:
原文链接:https://www.f2er.com/windows/364301.html$acl = Get-Acl \\remote_server\share_folder\HAL.9000 $acl.Access | %{$acl.RemoveAccessRule($_)}
#BUILTIN administrator $acl = Get-Acl \\remote_server\share_folder\HAL.9000 $permission = "BUILTIN\Administrators","FullControl","ContainerInherit,ObjectInherit","None","Allow" $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission $acl.SetAccessRule($accessRule) Set-Acl \\remote_server\share_folder\HAL.9000 $acl #Domain controller administrator $acl = Get-Acl \\remote_server\share_folder\HAL.9000 $permission = "DOMAINCONTROLLER\Administrators","Allow" $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission $acl.SetAccessRule($accessRule) Set-Acl \\remote_server\share_folder\HAL.9000 $acl
希望这会帮助别人:)