Hi to all
In this article I will talk about the basic management shell commands of Exchange Server 2010. The topics for this article are:
- Creating a new user
- Creating a new group
- Make the user a member of group
- Creating a secondary e-mail address for a user
- Giving send-as right for a mailbox to another user
- Creating a contact
- Forwarding e-mail messages to the contact
- Canceling the mail forwarding to the contact
- Deleting the contact
Exchange Server 2010 has a very nice improvement on its precessors. We can see the command line equivalent of what we do in graphical user interface. For example, when we open the properties window of a user in Exchange Management Console and make any change, an icon (
) on the left bottom corner of properties page is activated. By clicking on the icon, we can see the command line equivalent of the GUI action.
Now, it is time to start this article’s commands. Firstly, we will create a new Active Directory user with a mailbox. For this action, we open the Exchange Management Shell (Start -> All Programs -> Microsoft Exchange Server 2010 -> Exchange Management Shell). The command for a new user is New-Mailbox (by the way, your account must be at least Recipient Administrator to create a new user). The full command can be seen in Figure 1:

Figure 1: Creating a new user
The parameters for the command can be explained as below:
| Name | -> | The name of the user in Active Directory |
| OrganizationalUnit | -> | The AD OU in which the user acount will be created |
| UserPrincipalName | -> | Users logon name (UPN) |
| SamAccountName | -> | Users logon name for older operating systems |
| FirstName | -> | Users first name |
| LastName | -> | Users last name |
| ResetPasswordOnNextLogon | -> | Password changing setup on next logon |
| Database | -> | Name of database in which the user’s mailbox is created |
If you carefully examine the command, you can see that there is nothing about the password. In this situation, the password for the account is asked after running the main command. When we write the password, a new user is created under the Users OU of Active Directory, named mbteoman and an e-mail with the same name is associated with the account.
After creating our first account, let’s create a secondary e-mail address for the it. In addition to that, we will make this SMTP address default. To give a second SMTP address to mbteoman account, we have to disable the “Automatically update e-mail address according to e-mail policy” setup. Otherwise, we couldn’t add the second address for the account. For this reason, we disconnect the relationship between the account and e-mail address policy (Figure 2 – first line):
Set-Mailbox –EmailAddressPolicyEnabled $false –Identity ‘mstip.com/Users/mbteoman’
After that we add the secondary SMTP address (mborateoman@mstip.com) to our account (Figure 2 – second line) and also make this email address, the default one. To make the mborateoman@mstip.com address default, we write it in capital letters.

Figure 2: Addition of a secondary mail address for a user
Now our Active Directory user account has two email addresses and mborateoman@mstip.com is the default one. Let’s make this user a member of a security group, named Itstuff. This group will have the email address of itstuff@mstip.com and therefore any email destined to this address will be delivered to our user account also.
Figure 3: Creating a new group
To create a new group, we use the command New-DistributionGroup. The command that is shown in Figure 3 will create a security group named Itstuff in mstip.com/Users OU. The detailed parameter explanation is as follows:
| Name | -> | The name of the group |
| OrganizationalUnit | -> | The OU container in which the group will be created |
| SamAccountName | -> | the name of the group for older operating systems |
| Type | -> | the type of the group (can be security or distribution) |
| Alias | -> | Alias of the group (will be used for email creation of the group) |
After the creation of our new group, we can add our user account to this new group. For this purpose we use the command Add-DistributionGroupMember (Figure 4):
Add-DistributionGroupMember –Identity ‘mstip.com/Users/ITstuff’ –Member ‘mstip.com/Users/mbteoman’ -BypassSecurityGroupManagerCheck
Figure 4: Adding the user account to a group
Now i want to give a right to someone else for sending email on behalf of mbteoman account. This is send-as right. By the help of command below, we give administrator user the right of sending email on behalf of mbteoman account. For this reason, we use the Add-ADPermission command (Figure 5):

Figure 5: giving send-as right
Let’s talk about the contact subject now. We couldn’t include the email addresses from external domains to our exchange organization because exchange is very integrated into active directory. Therefore if a user wants his internal emails to be sent to an external email address of his own, we have to create a contact for this purpose. With the commands below, we create a contact which refers to an external email address and then we forward our user’s internal emails to the outer email address by using the contact. With the first command below, we create a contact, named mbteoman_msipucu, which is referring to mbteoman@msipucu.com external domain email address (Figure 6).
New-MailContact -ExternalEmailAddress ‘SMTP:mbteoman@msipucu.com’ -Name ‘mbteoman_msipucu’ -Alias ‘mbteoman_msipucu’ -FirstName ‘mbteoman_msipucu’ -Initials ‘’ -LastName ‘’

Figure 6: creating a new contact
With the second comman below, we forward the emails destined to mbteoman account to mbteoman@msipucu.com address. But here in this command, email is kept on theoriginal mailbox too (Figure 7).
Set-Mailbox -DeliverToMailboxAndForward $true -ForwardingAddress ‘mstip.com/Users/ mbteoman_msipucu’ -Identity ‘mstip.com/Users/mbteoman’
Figure 7: forwarding emails to an external address by using contact (a copy of email is kept in the original destination mailbox)
If we want emails to be forwarded without keeping a copy in the original destination mailbox, we have to write the command as it is shown below (Figure 8):
Set-Mailbox -ForwardingAddress ‘mstip.com/Users/mbteoman_msipucu’ -Identity ‘mstip.com/Users/mbteoman’

Figure 8: forwarding emails to an external address by using contact
Now we don’t need a contact anymore so let’s delete it from the command line. Firstly, we cancel the forwarding, and then secondly we delete it. By the first command below, we cancel the forwarding process for mbteoman account, using $Null parameter (Figure 9). And by the second command below, we delete the mbteoman_msipucu contact from Active Directory (Figure 10).
Set-Mailbox -ForwardingAddress $Null -Identity ‘mstip.com/Users/mbteoman’

Figure 9: Cancelling the forwarding process
Remove-MailContact -Identity ‘mstip.com/Users/mbteoman_msipucu’

Figure 10: deleting contact from active directory
That is it for now. I hope the article in which i try to explain the basic jobs, is useful for you.Bye for now.






RSS feed for comments on this post.




