title: Set-Acl error Active Directory permissions to computer account
body: <p>I want to use PowerShell to modify the access permissions to the computer account, adding other administrators.</p>
  
  <p>I'm able to do using <code>dsacls</code> command line without problem like this command</p>
  
  <pre><code>dsacls (Get-ADComputer $computername).DistinguishedName /g mydomain\xx882372:GA
  </code></pre>
  
  <p>But when I try to do the same using PowerShell, I get an error with the <code>Set-Acl</code> command:</p>
  
  <blockquote>
    <p>Set-Acl : Access is denied</p>
    
    <p>At line:1 char:1</p>
  </blockquote>
  
  <p>My PowerShell code is the following</p>
  
  <pre class="lang-cs prettyprint-override"><code>$computername = 'mycomputer'
  $aclpath = "AD:\" + (Get-ADComputer $computername).DistinguishedName
  $act = [System.Security.AccessControl.AccessControlType]::Allow
  $adrights = [System.DirectoryServices.ActiveDirectoryRights]::GenericAll
  $who = (Get-ADUser -Identity xx882372).Sid
  $acl = Get-Acl -Path $aclpath
  $ace = New-Object System.DirectoryServices.ActiveDirectoryAccessRule -ArgumentList $who, $adrights, $act #, $inheritanceType
  $acl.AddAccessRule($ace)
  Set-Acl -Path $aclpath -AclObject $acl
  </code></pre>
  
  <p>Any idea what could be wrong with <code>Set-Acl</code>?</p>