1

ADで新しく作成されたユーザーにいくつかの権利を設定しようとしています。フォルダーを作成したら、次のようにさまざまな権限を設定しようとします。

$Rights = [System.Security.AccessControl.FileSystemRights]::FullControl
$Inherit = @([System.Security.AccessControl.InheritanceFlags]::ContainerInherit,[System.Security.AccessControl.InheritanceFlags]::ObjectInherit)
$Propagation = [System.Security.AccessControl.PropagationFlags]::None
$Access =[System.Security.AccessControl.AccessControlType]::Allow
$ACL = New-Object System.Security.Principal.NTAccount "localdomain\$userprincipalname"
$objACE = New-Object System.Security.AccessControl.FileSystemAccessRule($ACL, $Rights, $Inherit, $Propagation, $Access)                     
$ACL = Get-Acl -Path $userDir
$ACL.AddAccessRule($objACE) 
Set-ACL -Path $userDir -AclObject $ACL 

私が得るエラーは、私が AddAccessRule に渡すパラメータに関連しています

Exception calling "AddAccessRule" with "1" argument(s): "Some or all identity references could not be translated."
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

しかし、ここではエラーが見られないので、別の目で見ていただければ幸いです。

4

1 に答える 1

2

わかりましたので、私の解決策は機能します。私が見つけることができる限り、フォルダーに権限を設定する方法です。

$Rights = [System.Security.AccessControl.FileSystemRights]::FullControl
$Inherit = @([System.Security.AccessControl.InheritanceFlags]::ContainerInherit,[System.Security.AccessControl.InheritanceFlags]::ObjectInherit)
$Propagation = [System.Security.AccessControl.PropagationFlags]::None
$Access =[System.Security.AccessControl.AccessControlType]::Allow
$ACL = New-Object System.Security.Principal.NTAccount "localdomain\$userprincipalname"
$objACE = New-Object System.Security.AccessControl.FileSystemAccessRule($ACL, $Rights,$Inherit, $Propagation, $Access)                     
$ACL = Get-Acl -Path $userDir
$ACL.AddAccessRule($objACE) 
Set-ACL -Path $userDir -AclObject $ACL 
于 2013-03-07T08:41:04.340 に答える