我正在尝试使用icacls修改文件上的ACL。我希望此文件归管理员所有,并且只能由管理员访问。我知道如何让管理员成为文件的所有者,我知道如何从安全列表中删除一个组,但如果我不知道其他组的名称,我不知道如何删除除管理员组之外的所有组。
我正在寻找一种方法来告诉Windows,我只想让管理员访问该文件,并删除任何其他用户/组。
我尝试使用通配符,但不起作用。
下面是我的脚本:
$domain = [Environment]::UserDomainName
$user = [Environment]::UserName
icacls $myinvocation.mycommand.path /setowner "$domain\$user" /T
icacls $myinvocation.mycommand.path /grant "$domain\$user"
icacls $myinvocation.mycommand.path发布于 2012-10-09 22:07:34
理论上,您可以在授予之后使用:r (请参阅Docs)。然而,在实践中,我无法做到这一点。我认为:r的意思是“只为指定的用户替换权限”。
我已经在Powershell中测试了以下解决方案,但它工作得很好。
# Reset the folder to just it's inherited permissions
icaclsname c:\temp\test /reset
# Then, disable inheritance and remove all inherited permissions
icacls c:\temp\test /inheritance:r
# Note the :r after grant. It's not now needed, but I've left it in anyway.
# Permissions replace previously granted explicit permissions.
# Also note the :F, where : is escaped with `. This grants FULL CONTROL.
# You can replace F with whatever level of control is required for you.
icacls c:\temp\test /grant:r $domain\$user`:Fhttps://stackoverflow.com/questions/12801852
复制相似问题