Exchange the PowerShell new & Modify & Delete Mailbox

Source: Internet
Author: User

in our daily use Exchange Management Shell the most should be the management of the mailbox. In this section, you will primarily describe the use of syntax commands in Exchange to Create, update, and delete mailboxes in your organization.

Let's look at an example first:

1. We can use the Exchange Management Shell to create an AD account that has the mailbox feature enabled . The syntax is as follows:

$password = Convertto-securestring-asplaintext Abc.123-force

new-mailbox-userprincipalname [email protected] '

-alias Dave '

-database DB01 '

-name Davejones '

-organizationalunit ' corp.robin.com/viplab/ Group Headquarters /sales "

-password $password '

-firstname Dave '

-lastname Jones '

-displayname ' Dave Jones '

650) this.width=650; "title=" 01.png "style=" height:333px;width:720px; "border=" 0 "hspace=" 0 "alt=" Wkiol1tad5fdmgblaaggj86ni_m343.jpg "src=" http://s3.51cto.com/wyfs02/M00/59/A1/wKioL1TaD5fDmgbLAAGGj86nI_ M343.jpg "width=" 720 "height=" 333 "/>

as you can see, create a mailbox-enabled AD user success, we go to Active Directory Users and computers see that the user has been created

650) this.width=650; "title=" 02.png "style=" Float:none; "alt=" wkiom1tadqobrgm3aaevk-h8-zy012.jpg "src=" http:/ S3.51cto.com/wyfs02/m00/59/a5/wkiom1tadqobrgm3aaevk-h8-zy012.jpg "/>

2. When the mailbox is created, we can make changes to the mailbox .

Set-mailbox-identity Dave '

-usedatabasequotadefaults $false '

-prohibitsendreceivequota 5GB '

-issuewarningquota 4GB

650) this.width=650; "title=" 03.png "style=" Float:none; "alt=" wkiol1tad5fh0g4daadc4eugfek501.jpg "src=" http:/ S3.51cto.com/wyfs02/m01/59/a1/wkiol1tad5fh0g4daadc4eugfek501.jpg "/>

Back to ECP interface, you can also see whether the changes have taken effect, such as:

650) this.width=650; "title=" 04.png "style=" Float:none; "alt=" wkiom1tadqotzr5vaajixih4twq138.jpg "src=" http:/ S3.51cto.com/wyfs02/m01/59/a5/wkiom1tadqotzr5vaajixih4twq138.jpg "/>

3. To disable the mailbox feature for an AD User, use the following syntax:

Disable-mailbox-identity dave-confirm: $false

650) this.width=650; "title=" 05.png "style=" height:151px;width:720px; "border=" 0 "hspace=" 0 "alt=" Wkiol1tad5ftgddyaab-wo6rglq245.jpg "src=" http://s3.51cto.com/wyfs02/M02/59/A1/ Wkiol1tad5ftgddyaab-wo6rglq245.jpg "width=" 720 "height=" 151 "/>

How are these instructions executed?

in the example above, when using the New-mailbox command to create a mailbox account, we need to specify a -password parameter, and then you need to finalize a secure string object for this value. We used convertto-securestring to create a $password variable to save as a secure, encrypted string. Then assign the variable $password to the -password parameter. Of course, it is not always important to store the object in a variable first, or you can use the following syntax:

new-mailbox-userprincipalname [email protected] '

-alias Dave '

-database DB01 '

-name Davejones '

-organizationalunit ' corp.robin.com/viplab/ Group Headquarters /sales "

-password (convertto-securestring-asplaintext [email protected]-force) '

-firstname Dave '

-lastname Jones '

-displayname ' Dave Jones '

It is also important to note that the password we specify here must conform to our password policy and must meet the minimum password length and complexity requirements.

before we use New-mailbox command to create a mailbox, you only need to specify a few parameters, but New-mailbox supports a number of useful parameters. You can use get-help new-mailbox–detailed to view New-mailbox supports those parameters.

when using New-mailbox when a mailbox account is created, this command creates a AD user, and then enable the mailbox feature. We can also enable the mailbox feature for an existing AD account, using the enable-mailbox command with the following syntax:

Enable-mailbox Albert–database DB01

650) this.width=650; "title=" 06.png "style=" height:201px;width:720px; "border=" 0 "hspace=" 0 "alt=" Wkiom1tadqoz6we1aadcbxvl2uq463.jpg "src=" http://s3.51cto.com/wyfs02/M02/59/A5/ Wkiom1tadqoz6we1aadcbxvl2uq463.jpg "width=" 720 "height=" 201 "/>

When you enable a mailbox, we only need to specify AD User's Identity . In the previous example, you can also specify the database for the mailbox account. Enable-mailbox supports a number of parameters that allow us to customize the properties for creating mailboxes. You can use the following command to enable users who are not mailbox-enabled in AD:

Get-user-recipienttypedetails User |

Enable-mailbox-database DB01

Here we use Get-user command, by specifying -recipienttypedetails the value of the parameter is User to filter AD There are no mailbox-enabled users in the domain. The output information is then passed to the enable-mailbox command via a pipe character, and the user mailbox function is enabled by specifying some other parameters.

when the user's mailbox has been enabled, we can also use the Set-mailbox command, such as one of the following commands:

get-mailbox-organizationalunit corp.robin.com/viplab/ Group Headquarters / Technology Center |

Set-mailbox-usedatabasequotadefaults $false '

-prohibitsendreceivequota 5GB '

-issuewarningquota 4GB

650) this.width=650; "title=" 07.png "style=" height:175px;width:720px; "border=" 0 "hspace=" 0 "alt=" Wkiol1tad5fx5vtdaadhravzum0177.jpg "src=" http://s3.51cto.com/wyfs02/M00/59/A1/ Wkiol1tad5fx5vtdaadhravzum0177.jpg "width=" 720 "height=" 175 "/>

in this command line, we filter by aOUmailbox users under, and then through theSet-mailboxcommand to configure mailbox quotas. With theEnable-mailbox, on the contrary there areDisable-mailboxcommand to disconnect from the mailbox. By default, disconnected mailboxes are retained -days. This can be updated by modifying the mailbox database settings. In addition, we can also useRemove-mailboxcommand, but be aware that when you use this command,ADthe use of the domain will also be deleted. If you disable mailbox functionality only, you should useDisable-mailboxcommand instead of usingRemove-mailboxcommand.

to delete a mailbox account, AD domain, you can use the following syntax:

Remove-mailbox-identity dave-confirm: $false

More examples:

use in front New-mailbox example, we use the convertto-securestring The command assigns a secure string to the -password parameters. This is important when we use scripting to automate, and more so, you can allow operators to interact. For example: When creating a script to create a mailbox, you can use the following command to let the operator enter the password:

$pass = read-host "Enter Password" –assecurestring

650) this.width=650; "title=" 08.png "style=" Float:none; "alt=" wkiom1tadqtzr9saaabzydo6lyq016.jpg "src=" http:/ S3.51cto.com/wyfs02/m00/59/a5/wkiom1tadqtzr9saaabzydo6lyq016.jpg "/>

When we enter a password, when we use the New-mailbox , you can use $pass variable Assignment to -password parameters.

In addition, you can use the following command to assign a value

New-mailbox-name dave-userprincipalname [email protected] '

-password (get-credential). Password

set up AD Properties

when we are using New-mailbox when you go to create a mailbox, some properties are not available, such as City, country, company, and department attributes, but we can Set-mailbox command to achieve.

set-user–identity dave–office–city Guangzhou –state China

can use get-help set-user–detailed to check out more helpful information.

This article from "Robin's Home" blog, declined reprint!

Exchange the PowerShell new & Modify & Delete Mailbox

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.