Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
签入powershell权限字符串有效_Powershell_Acl - Fatal编程技术网

签入powershell权限字符串有效

签入powershell权限字符串有效,powershell,acl,Powershell,Acl,我尝试实现一个脚本,根据某些条件更改文件夹结构权限。到目前为止,我使用设置权限 $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("$($group.Name)", @("$($group.Value.rights)"), "ContainerInherit, ObjectInherit", "None", "$($group.Value.type)") $aclFolder.

我尝试实现一个脚本,根据某些条件更改文件夹结构权限。到目前为止,我使用设置权限

    $accessRule = New-Object  System.Security.AccessControl.FileSystemAccessRule("$($group.Name)", @("$($group.Value.rights)"), "ContainerInherit, ObjectInherit", "None", "$($group.Value.type)")
    $aclFolder.AddAccessRule($accessRule)
    Set-Acl $folder $aclFolder
到目前为止,它是有效的。但该脚本当前假定权限确实存在。否则,AddAccessRule命令将抛出并出错


是否有任何方法可以识别权限的存在

使用
获取Acl$文件夹
读取当前Acl并验证是否已应用任何权限。

也许我应该给出更详细的描述:$($group.Name)可以是不存在的组的字符串。当我应用一个不存在的组/用户时,它将抛出一个错误。我想通过首先检查来捕获这个错误,字符串确实存在。