PowerShell bulk separates SMTP mailboxes and creates new user mailboxes with this

Source: Internet
Author: User

First of all, demand:

Users here with a multi-domain mailbox, is a user name will have multiple mailboxes, but the suffix is different, such as @ny9s.com @ny9s. CN @ny9s. co.jp. Depending on the business needs, you need to send the message to the user when the different suffixes are displayed separately.

This requirement is not very simple to solve, because we know that in exchange, users can not and QQ mailbox, at any time to switch their e-mail address. You can set up multiple mailboxes as a receive, but there is no way to change the sending address at any time.


Here's how to fix it:

1. Detach the @ny9s.co.jp address from the user's mailbox

2, using the user's Chinese name + (Cream of Japan) as the Chinese name, the original English name +ny9sjapan as a new e-mail address. Set a password in bulk [email protected]

That's how it's done.

Old e-mail: nine uncle [email protected] login name Jiushu

New e-mail: Nine uncle (Cream Japan) [email protected] login name JIushu.ny9sjapan


Use PowerShell to achieve, of course, with the help of CSV, save as UTF8 format, the content is as follows:

Name,alias

Uncle Jiu, Jiushu


The following are the separated parts

#批量从csv中摘除某个特定邮件地址, #Powered by nine tert cls# define variable $removeaddress = "@" + "ny9s.co.jp" Import-csv-path e:\rlpl.csv | foreach {#进入循环, $removeaddress = $_.alias+ $removeaddressecho $removeaddressSet-mailbox $_.name-emailaddresses @{ Remove= "$removeaddress"} #清洗变量 to prevent the next loop when the variable is superimposed $removeaddress = "@" + "ny9sco.jp"}


Here's the section to create a mailbox

#批量从csv中创建邮箱, #Powered by nine tert cls# configuration password $pass = convertto-securestring-asplaintext [email protected]-force#ny9s is the local UPN, Ny9sjapan is the separated domain name $ny9s = "@" + "ny9s.com" $ny 9sjapan = ". Ny9sjapan" + "@" + "ny9sjapan.co.jp" #从csv中获取数据Import-csv-path e:\ Rlpl.csv | foreach {#获取循环的upn和特定完整邮件地址 $CB = $_.alias+ $ny 9S$CCB = $_.alias+ $ny 9sjapan$ab = "(Creamy Japan)" $abb = $_.name+ $ab # Create a mailbox New-mailbox-name $abb-alias $_.alias-organizationalunit ' ny9s.com/non-user account/mailbox '-userprincipalname $CB- sAMAccountName $_.alias-firstname '-initials '-lastname '-database ' jiuzige '-password $pass-ResetPasswordOnNextLo Gon $false-primarysmtpaddress $CCB # By the way to a specific security group add-distributiongroupmember-identity "Haojiyou"-member $_.name}


It is important to note that two scripts can be put together and run in one file. They are two separate loops.

This article is from the "Nine uncle-Microsoft Private Cloud" blog, please make sure to keep this source http://jiushu.blog.51cto.com/972756/1662275

PowerShell bulk separates SMTP mailboxes and creates new user mailboxes with this

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.