[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 570
  • Last Modified:

need a quest AD cmdlets or posh script to create bulk "mail enabled" users

can someone provide a quest AD cmdlets script to create bulk mail enabled users from an input CSV?

[not mailbox enabled]

many thanks

S.
0
siber1
Asked:
siber1
2 Solutions
 
Will SzymkowskiSenior Solution ArchitectCommented:
I am assuming that you want to create "new" mail users. If so use the powershell command below to accomplish this...

You need to construct your CSV file like the below example for this to work properly...

Name        ExternalEmailAddress   UserPrincipalName    sAMAccountName  Password
Jon Smith  jsmith@abc.com            jsmith@domain.com  jsmith                       P@ssworD
Mac Lin     Mlin@abc.com               mlin@domain.com     mlin                           P@ssworD
etc.....

$UserList = import-csv "c:\yourCSVhere"
foreach ($User in $UserList) {
$User.Name
$User.ExternalEmailAddress
$User.UserPrincipalName
$User.sAMAccountName
$User.Password
New-MailUser -Name $User.Name -ExternalEmailAddress $User.ExternalEmailAddress -UserPrincipalName $User.UserPrincipalName -sAMAccountName $User.sAMAccountName -Password $User.Password -AsSecureString
}

Open in new window


Will.
0
 
SubsunCommented:
Try this..

You need to run the code from Exchange Management Shell..
$password = convertto-securestring "p@ssw0rd" -asplaintext -force
Import-Csv C:\Test.csv | % {
New-MailUser `
	-Name "$($_.LastName) $($_.FirstName)" `
	-FirstName $_.FirstName `
	-LastName $_.LastName `
	-DisplayName "$($_.LastName) $($_.FirstName)" `
	-Password $password `
	-ExternalEmailAddress $_.Email `
	-UserPrincipalName "$($_.Account)@testdomain.com" `
	-OrganizationalUnit "Testdomain.com/mailenabled"
}

Open in new window

Sample C:\Test.csv file..
FirstName,LastName,Account,Email
Test,User,TUser,Tuser@Test.com
Test1,User1,TUser1,Tuser1@Test.com

Open in new window

0
 
siber1Author Commented:
thanks Subsun / Spec01 both solutions work great.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Tackle projects and never again get stuck behind a technical roadblock.
Join Now