Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Bulk create exchange 2007 users that already have an Active Directory account

$
0
0

My goal is to bulk create user mailboxes in exchange 2007.  The users have active directory accounts already.

The data file looks like the one shown below

SAMName;Fname;Lname;facility;OU;Telephone;Position;DisplayName;EmployeeNUM;HireDate;State;EmployeeID;Employmentstatus
Test12;Test;User1;Testou1;OU=Testou1,OU=Facilities,DC=secret,DC=com;8675309;Administrator;Test User1;1111;03 06 2012;CA;2222;NewHire
Test23;Test;User2;Testou1;OU=Testou1,OU=Facilities,DC=secret,DC=com;8675309;Assistant;Test User2;2222;03 06 2012;CA;3333;NewHire
Test34;Test;User3;Testou1;OU=Testou1,OU=Facilities,DC=secret,DC=com;8675309;Facility Director;Test User3;3333;03 06 2012;CA;4444;NewHire
Test56;Test;User4;Testou1;OU=Testou1,OU=Facilities,DC=secret,DC=com;8675309;Maintenance Director;Test User4;4444;03 06 2012;CA;5555;NewHire
Test78;Test;User5;Testou1;OU=Testou1,OU=Facilities,DC=secret,DC=com;8675309;Dining Director;Test User5;5555;03 06 2012;CA;7777;NewHire
Test90;Test;User6;Testou1;OU=Testou1,OU=Facilities,DC=secret,DC=com;8675309;IT Staff;Test User6;7777;03 06 2012;CA;1111;NewHire

I can easily import one user with the power shell script shown below

$User = (Get-aduser -Identity Test12).DistinguishedName
Enable-Mailbox -Identity $User -Database "Secret-mailserver\SecretCompanyDB1"

As you noticed Test12 is the first account in the csv file. I now need to figure out how to make that first column (SAMName) in the .csv dynamically read line by line and accounts created line by line until the end of the file is reached.

I figured I could start out by reading the .csv file line by line as shown below and simply create the user based on the variable $SAMName but as you are aware that idea did not work.

$Users = Import-Csv -Delimiter ";" -Path ".\test_users.csv" 
foreach ($User in $Users) 

$User = (Get-aduser -Identity $SAMName).DistinguishedName
Enable-Mailbox -Identity $User -Database "Secret-mailserver\SecretCompanyDB1"

}

Any suggestions to add the mailboxes from the .csv file would be greatly appreciated.  Thanks in advance!


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>