如何将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 $AclI 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 ReadAnd if it's a Domain Group just replace LocalComputerName with the Domain Name.
更多推荐
发布评论