在PowerShell中删除文件的访问规则

发布于 2025-02-03 12:56:24 字数 801 浏览 2 评论 0 原文

我有以下内容:

$dir = ".\AES.key"
$Acl = Get-Acl -Path $dir
$Acl.Access | ft

返回我:

FileSystemRights AccessControlType IdentityReference            IsInherited InheritanceFlags PropagationFlags
---------------- ----------------- -----------------            ----------- ---------------- ----------------
     FullControl             Allow NT-AUTORITÄT\SYSTEM                 True             None             None
     FullControl             Allow VORDEFINIERT\Administratoren        True             None             None
     FullControl             Allow GOOGLE\steso                        True             None             None

是否有任何方法可以删除所有条目,除了“ google \ steso ”,powershell。提前致谢

I have the following:

$dir = ".\AES.key"
$Acl = Get-Acl -Path $dir
$Acl.Access | ft

Which returns me:

FileSystemRights AccessControlType IdentityReference            IsInherited InheritanceFlags PropagationFlags
---------------- ----------------- -----------------            ----------- ---------------- ----------------
     FullControl             Allow NT-AUTORITÄT\SYSTEM                 True             None             None
     FullControl             Allow VORDEFINIERT\Administratoren        True             None             None
     FullControl             Allow GOOGLE\steso                        True             None             None

Is there any way to delete all entries except "GOOGLE\steso" from PowerShell. Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

菊凝晚露 2025-02-10 12:56:25

我将其放在这里,因为单个评论字符串将太长。

您所显示的是“继承权限”

***常见的限制是,如果不明确删除继承权,就无法删除继承的权限。***

详细信息在这里:


$acl.SetAccessRuleProtection($true,$false) | 
Set-Acl

这可能会导致您的问题,而无需仔细确定为什么需要这样做。这意味着,如果您打破继承,那么继承的权限将不再存在删除。

也请参阅其他讨论:

https://social.technet.microsoft.com/forums/forums/ie/en-us/634bfe7d-132a-4a8e-9791-9791-329a6c096c096aab/ppowershell-script - 可见的属性 - parrom-parent-object-and-remove-modify

I am putting this here as it will be too long for a single comment string.

What you are showing is 'Inherited permission'

*** The common refrain is, you cannot remove inherited permissions without specifically removing inheritance.***

Details are here:

https://msdn.microsoft.com/en-us/library/system.security.accesscontrol.objectsecurity.setaccessruleprotection.aspx

$acl.SetAccessRuleProtection($true,$false) | 
Set-Acl

This can cause you issues without carefully determining why you need to do this. Meaning that if you break the inheritance, then the inherited permissions won't be there anymore to remove.

See this other discussion as well:

https://social.technet.microsoft.com/Forums/ie/en-US/634bfe7d-132a-4a8e-9791-329a6c096aab/powershell-script-to-disable-inherit-from-parent-object-and-remove-modify

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文