HowTo Create Testusers Exchange 2010

Example one

This command creates an Active Directory user for John Smith in the CorpUsers OU, with a mailbox on the UserDatastore database, and an initial password that must be changed at next logon. It first prompts you for the password which it will store “-AsSecureString” meaning that it cannot be displayed again.

$password = Read-Host "Enter password" -AsSecureString
New-Mailbox -UserPrincipalName -Alias john
-Database "UserDatastore" -Name JohnSmith –OrganizationalUnit
CorpUsers -Password $password -FirstName John -LastName Smith
-DisplayName "John Smith" -ResetPasswordOnNextLogon $True

Example two

This command creates a resource mailbox for a conference room in the CorpResources OU, using the CorpResources database, and requiring the password to be set at next logon. This sets the alias as ChaConf1, and will prompt you for the password once you hit enter.

New-Mailbox -UserPrincipalName
-Alias ChaConf1 -Name CharlotteConferenceRoom1 -Database
"CorpResources" -OrganizationalUnit ConferenceRooms -Room
-ResetPasswordOnNextLogon $True

Example three

This command creates a mailbox for an existing user without a mailbox.

Enable-Mailbox -Identity:’ Smith'
-Alias:'JoeSmith' -Database: 'UserDatastore'

This is just a taste of what you can do with PowerShell and the new-mailbox command. There is even more information available about using the new-mailbox command using the online help in the shell, or on TechNet.


This would mailbox enable every user in the "finance" OU:

Get-User -OrganizationalUnit | Enable-Mailbox