Link to home
Start Free TrialLog in
Avatar of Indie101
Indie101

asked on

Powershell script to bulk add AD accounts, mailboxes, password and security groups

Hi urgent query looking to get this done

Found below script at http://www.morgantechspace.com/2014/04/Create-Bulk-AD-Users-from-CSV-using-Powershell-Script.html

Have a test csv attached, I want to add exchange mailboxes and also 3 more security groups "Test members" "Test 2017" and "Test Wifi" what is the best way to do this?

Would it be just Add-ADgroup member "Domain Admins" "Test members" Test 2017" Test Wifi" $_."samAccountName";

Import-Module ActiveDirectory
Import-Csv "C:\Scripts\NewUsers.csv" | ForEach-Object {
 $userPrincinpal = $_."samAccountName" + "@TestDomain.Local"
New-ADUser -Name $_.Name `
 -Path $_."ParentOU" `
 -SamAccountName  $_."samAccountName" `
 -UserPrincipalName  $userPrincinpal `
 -AccountPassword (ConvertTo-SecureString "MyPassword123" -AsPlainText -Force) `
 -ChangePasswordAtLogon $true  `
 -Enabled $true `
 -EmailAddress $_."EmailAddress"
Add-ADGroupMember "Domain Admins" $_."samAccountName";
}

Test.csv
ASKER CERTIFIED SOLUTION
Avatar of Sean
Sean
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Indie101
Indie101

ASKER

Thanks Sean good point on domain admins is there a handy way to enable multiple mailboxes and add multiple users to those test groups?
Using exchange 2010 in a hybrid office 365 environment