我正在开发一个小脚本,通过添加额外的权限来修改文件夹上的ACL;我执行“Set-ACL”命令时得到错误。请让我知道我做错了什么。
$AddAccessRule = New-Object security.accesscontrol.filesystemaccessrul("CREATOROWNER",@("ReadAndExecute,Synchronize"),"ContainerInherit,Objectinherit","Inheritonly","Allow")
$objacl = get-acl $FolderPath
$ObjAcl.AddAccessRule($AddAccessRule)
Set-acl $FolderPath $objacl
当我执行它时会发生以下错误;
使用“1”参数调用“AddAccessRule”的异常:“部分或全部身份引用无法转换。” 在C:\ Users \ kakulva \ Desktop \ Scripts \ CreatorOwner \ ACL.ps1:10 char:1 + $ ObjAcl.AddAccessRule($ AddAccessRule) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:NotSpecified:(:) [],MethodInvocationException + FullyQualifiedErrorId:IdentityNotMappedException
如果需要任何排队或澄清,请告诉我。
答案 0 :(得分:3)
这可行(或至少不会返回错误):
$AddAccessRule = New-Object 'security.accesscontrol.filesystemaccessrulE'("CREATOR OWNER",@("ReadAndExecute,Synchronize"),"ContainerInherit,Objectinherit","Inheritonly","Allow")
$objacl = get-acl C:\A
$ObjAcl.AddAccessRule($AddAccessRule)
Set-acl -PATH C:\A $objacl