title: How to add user in a Active directory Group using powershell
body: <p>The code I have used to create user is: </p>
  
  <pre><code> Import-Module ActiveDirectory
  
   $total = 2
   for ($userIndex=0; $userIndex -lt $total; $userIndex++) 
   { 
    $userID = “{0:0000}” -f ($userIndex + 1)
    $userName = “Super.admin$userID”
  
    Write-Host “Creating user” ($userIndex + 1) “of” $total “:” $userName
  
    New-ADUser `
     -AccountPassword (ConvertTo-SecureString “admin@123” -AsPlainText -Force) `
     -City “City” `
     -Company “Company” `
     -Country “US” `
     -Department “Department” `
     -Description (“TEST ACCOUNT ” + $userID + “: This user account does not represent a real user and is meant for test purposes only”)`
     -DisplayName “Test User ($userID)” `
     -Division “Division” `
     -EmailAddress “$userName@DESMOSEDICI.local” `
     -EmployeeNumber “$userID” `
     -EmployeeID “ISED$userID” `
     -Enabled $true `
     -Fax “703-555-$userID” `
     -GivenName “Test” `
     -HomePhone “703-556-$userID” `
     -Initials “TU$userID” `
     -MobilePhone “703-557-$userID” `
     -Name “Super.Admin ($userID)” `
     -Office “Office: $userID”`
     -OfficePhone “703-558-$userID” `
     -Organization “Organization” `
     -Path  "OU=BusinessUnit,DC=Domain,DC=com" `
     -POBox “PO Box $userID”`
     -PostalCode $userID `
     -SamAccountName $userName `
     -State “VA – Virginia” `
     -StreetAddress “$userID Any Street” `
     -Surname “User ($userID)” `
     -Title “Title” `
     -UserPrincipalName “$userName@Domain.com“
   }
  </code></pre>
  
  <p>Under my business unit group HR is created. How can I add a user in this group or create the users and assign the HR group to the users using the above script?
  I tried to change the <code>-Path</code></p>
  
  <pre><code>-Path "CN=HR,OU=Utility,DC=DESMOSEDICI,DC=com"
  </code></pre>
  
  <p>But it is not working.</p>