title: Azure ad add member from one group to another
body: <p>I'm looking to learn some powershell since not a lot of people in my organisation know a lot about coding. I just started using PS and it was a long time since i wrote any code whatsoever so I'm just trying to do a simple script that gets all the group members from one Azure AD group and adds them to another. Been looking around and taking bits from here and there and this is what i got so far.</p>
  
  <pre><code>$Credential = Get-Credential
  Connect-AzureAD -Credential $Credential
  
  
  $group1 = "ObjectId pulled from AAD"
  $group2 = "ObjectId pulled from AAD"
  
  $membersGroup1 = Get-AzureADGroupMember -ObjectId $group1
  
  foreach($member in $membersGroup1)
  {
      $currentuser = Get-AzureADUser -ObjectId $member | select objectid
      Add-AzureADGroupMember -ObjectId $group2 -RefObjectId $currentuser.objectid
  
  }
  Disconnect-AzureAD
  </code></pre>
  
  <p>The errors i am getting is:</p>
  
  <blockquote>
    <p>$currentuser = Get-AzureADUser -ObjectId $member | select obj ...
    Add-AzureADGroupMember : Cannot bind argument to parameter
    'RefObjectId' because it is null.</p>
  </blockquote>