search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Exchange Server, Windows Powershell | 1 Comment | 14,499 views | 29/11/2009 21:01

I wrote a function for Hosted Exchange 2010 to create a new mailbox on Exchange Server 2010.

1
2
3
4
5
6
7
function Add-MailUser
{
Param ($UserID, $FirstName, $LastName, $CustomerOU)
    $ADDomain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
    $ADDomainName = $ADDomain.Name
    Enable-Mailbox -Identity "$ADDomainName/$CustomerOU/$FirstName $LastName" -Alias "$UserID"
}

Usage of function:

Add-MailUser –UserID “2452” –FirstName “Yusuf” –LastName “Ozturk” -CustomerOU “Users”

I used System.Directory.Services to get Active Directory domain. Lets see how does it work:

dservices

CustomerOU is the base of your user container. Just type your OU name like “Exchange” or “Users”.