尝试向文件夹添加用户权限但出现错误

时间:2018-12-04 21:39:46

标签: powershell permissions folder-permissions

到目前为止,这是我的代码:

$path = "\\Tanks\users\Derick\My Documents"
$AdAccount = 'domain\userDerick'
$Acl = Get-Acl ($path)
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule ("$AdAccount", "FullControl", "ContainerInherit, ObjectInherit", "None", "Allow")
$acl.AddAccessRule($rule)

这是我得到的错误:

error:  Permissions.ps1  
Exception calling "AddAccessRule" with "1" argument(s): "Some or all identity
references could not be translated."  
At C:\Users\Derick\Desktop\updaing Permissions.ps1:9 char:1  
+ $acl.AddAccessRule($rule)  
+ ~~~~~~~~~~~~~~~~~~~~~~~~~  
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException  
    + FullyQualifiedErrorId : IdentityNotMappedException  

我该怎么办?

0 个答案:

没有答案