首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >icacls从ACL中删除所有组

icacls从ACL中删除所有组
EN

Stack Overflow用户
提问于 2012-10-09 22:04:15
回答 1查看 10.5K关注 0票数 1

我正在尝试使用icacls修改文件上的ACL。我希望此文件归管理员所有,并且只能由管理员访问。我知道如何让管理员成为文件的所有者,我知道如何从安全列表中删除一个组,但如果我不知道其他组的名称,我不知道如何删除除管理员组之外的所有组。

我正在寻找一种方法来告诉Windows,我只想让管理员访问该文件,并删除任何其他用户/组。

我尝试使用通配符,但不起作用。

下面是我的脚本:

代码语言:javascript
复制
$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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-09 22:07:34

理论上,您可以在授予之后使用:r (请参阅Docs)。然而,在实践中,我无法做到这一点。我认为:r的意思是“只为指定的用户替换权限”。

我已经在Powershell中测试了以下解决方案,但它工作得很好。

代码语言:javascript
复制
# 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`:F
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12801852

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档