如何将Localhost \ Users + READ权限添加到Powershell中的文件夹(How can I add Localhost\Users + READ permissions t

编程入门 行业动态 更新时间:2024-10-27 09:37:25
如何将Localhost \ Users + READ权限添加到Powershell中的文件夹(How can I add Localhost\Users + READ permissions to a folder in Powershell)

我试过了:

$Folderpath='D:\DATA\' $user_account='USERS' $Acl = Get-Acl $Folderpath $Ar = New-Object system.Security.AccessControl.FileSystemAccessRule($user_account, "Read", "ContainerInherit, ObjectInherit", "None", "Allow") $Acl.Setaccessrule($Ar) Set-Acl $Folderpath $Acl

我收到以下错误:

Set-Acl:不允许安全标识符为此对象的所有者。

我不希望USERS成为所有者,只有READ。

I tried:

$Folderpath='D:\DATA\' $user_account='USERS' $Acl = Get-Acl $Folderpath $Ar = New-Object system.Security.AccessControl.FileSystemAccessRule($user_account, "Read", "ContainerInherit, ObjectInherit", "None", "Allow") $Acl.Setaccessrule($Ar) Set-Acl $Folderpath $Acl

I get following error:

Set-Acl : The security identifier is not allowed to be the owner of this object.

I do not want USERS to be the owner tho, only to have READ.

最满意答案

如果您使用文件系统安全性PowerShell模块,则此任务变得更加容易,因为您可以使用Add-NTFSAccess ,它以更合理的方式运行:

Add-NTFSAccess -Path D:\DATA -Account 'LocalComputerName\Username' -AccessRights Read

如果它是一个域组,只需用域名替换LocalComputerName 。

If you use the File System Security PowerShell Module this task becomes much easier as you can use Add-NTFSAccess, which acts in a much more logical manner:

Add-NTFSAccess -Path D:\DATA -Account 'LocalComputerName\Username' -AccessRights Read

And if it's a Domain Group just replace LocalComputerName with the Domain Name.

更多推荐

本文发布于:2023-07-22 19:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1222717.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   文件夹   权限   Users   Localhost

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!