title: Insufficient access rights to perform the operation -- Powershell
body: <p>I am writing a simple script to copy AD group membership from one user to the other. I am doing it using the ActiveDirectory module only.</p>
  
  <p>The script looks like it would work and does work up until I try to ad the groups to the user.</p>
  
  <p>Code:</p>
  
  <pre><code>import-module ActiveDirectory
  $templateUser = get-ADUser user1
  $targetUser = getADUser user2
  
  $groups =get-adprincipalgroupmembership $templateUser
  $groups2 = get-ADPrincipalGroupMembership $targetUser
  
  foreach($group in $groups) {
      add-adGroupMember $group $targetUser
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Add-ADGroupMember : insufficient access rights to performt the operation
  At line:9 char:18
  + FullyQualifiedErrorID : Insufficient access rights to perform the operation,Microsoft.ActiveDirectory.Management.Commands.AddADGroupMember
  </code></pre>
  
  <p>Notes/Thoughts:</p>
  
  <p>I am logged in as a normal user, but I ran the powershell as a different user (my admin account). I am not a local admin, but I am an admin on the domain. I am able to add the user to groups if I launch the AD Tools and do it manually (I have permissions to add to those groups). </p>
  
  <p>Edit: </p>
  
  <p>Run the powershell as admin.</p>