Monday, June 7, 2010

Exchange 2007-->Bulk Create Mailbox

Create a CSV file with columns as below:

DatabasePasswordName OUAliasfqdn




##Create password as secure string

$data = import-csv $args[0]

## Create a function to convert password into a secure string

function New-SecureString([string] $plainText)

{

$secureString = new-object System.Security.SecureString

foreach($char in $plainText.ToCharArray())

{

$secureString.AppendChar($char)

}

$secureString

}

foreach ($i in $data)

{

$ss = new-securestring $i.password

$upn = $i.alias + "@" + $i.fqdn

new-mailbox -Password $ss -Database $i.database -UserPrincipalName $upn -Name $i.name -OrganizationalUnit $i.ou

}

No comments:

Post a Comment