So I'm coming tot he end of my first powershell project, I have been creating a script to import users into active directory from a CSV file containing only first and surnames.
Import-Csv users.csv |
select Surname,
@{n='GivenName';e={$_.'FirstName'}},
@{n='samaccountname';e={$_.FirstName.substring(0,2) + $_.Surname}},
@{n='UserPrincipalName';e={$_.FirstName.substring(0,2) + $_.Surname}},
@{n='Name';e={$_.'FirstName' + ' ' + $_.'Surname'}} |
New-ADUser -Enabled $true -AccountPassword (ConvertTo-SecureString -AsPlainText "Password1" -Force) -ChangePasswordAtLogon $true -Path "OU=Intake 20XX,OU=Students,OU=Ravenloft users,DC=RAVENLOFT,DC=test" -ProfilePath {"\\TESTSVR\Profiles$\Intake20XX\" +$_.SamAccountName} -HomeDrive "D:" -HomeDirectory {"\\TESTSVR\Work$\Intake20XX\" +$_.SamAccountName}
Now my last job for this would be to add all of these new users to a group called StudentGroup, I understand there is no parameter in new-aduser to edit the "Member of" field in AD. So what would be the best way to go about doing this?