My newest project involves setting up a greenfield Exchange 2016 environment in a Resource Forest. From my searches, there's not a lot of info out there for creating hundreds ok, thousands of Linked Mailboxes so I'll show you how to create them using PowerShell.
First, you'll need to create your CSV which we'll later import into the Exchange Management Shell (EMS).
You can add as many headings as you like, but the ones I use will be:
Alias, Name, LinkedDC, MasterAccount, UPN, OU
Breakdown of the headings:
Alias - this will be new email alias for the Linked Mailbox in the Resource Forest
Name - this will be new DisplayName for the Linked Mailbox in the Resource Forest
LinkedDC - this will be a Domain Controller in the Accounts Forest
MasterAccount - this will be the Master User Account in the Accounts Forest
UPN - this will be the new User Principal Name for the Linked Mailbox in the Resource Forest
OU - this will be Organizational Unit where the disabled account for the Linked Mailbox will be created in the Resource Forest
Under the headings, you'll add the user info; so the finished product will look like so:
**Note** You'll of course change "Name", "dc.accountdomain.com", "accountdomain.com\username#", "username#@resourcedomain.com", "resourcedomain.com\linked mailboxes\Users" to match your environment.
For instance enabling my Linked Mailbox would look like:
stacey,Stacey Branham,dc.exchangeitup.com,exchangeitup.com\Stacey,staceybranham@us-exchangeitup.com,us-exchangeitup.com\Linked Mailboxes\Users
Once you have your CSV built, save it as mailboxes.csv and copy it over to an Exchange server in a location of your choosing like C:\Scripts.
Fire up the EMS, and cd to the CSV file location:
cd C:\Scripts
Then we'll need to pass our Account Forest credentials into the EMS - you only have to do this once.
$cred = Get-Credential
You'll get a logon prompt, where you'll input your domain admin creds for the Account Forest.
Next we'll import the CSV to create those Linked Mailboxes:
Import-Csv “mailboxes.csv” | ForEach {New-Mailbox -Alias $_.Alias -Name $_.Name -LinkedDomainController $_.DC -LinkedMasterAccount $_.MasterAccount -UserPrincipalName $_.UPN -OrganizationalUnit $_.OU -LinkedCredential $cred}
What the cmdlet does is it grabs the info from the CSV and creates a mailbox for each user, using the name and alias provided, by connecting back to the Accounts Forest domain controller using your credentials.
Now you can either check the EAC under Recipients or in the EMS by running:
Get-Mailbox | select Name,Database,RecipientTypeDetails
You should see those newly created Linked Mailboxes!
Thank you for the post, was pertty helpfull.
ReplyDeleteTwo comments
1. If you call the Domain Controller DC in the cmdlet the field in the CSV file also should be named DC
2. When I used it on Windows 2016 /Exchange 2016 OT worked without the domain part just use the OU path
Hey Mike, thanks for the heads-up...cmdlet corrected to match CSV sample
DeleteHey Thank you for the post.
ReplyDeleteIn my case I already have both existing users in Account Forest and Resource Forest. I would like to convert the one in the Resource Forest to Linked Mailbox using Set-Mailbox. I do not want to create a new mailbox. Do you have any idea how I could do this?
I have figured this out so far. However, I would now like to query beforehand if the user is already shared mailbox or remote mailbox.
DeleteSo how do I query the msExchRemoteRecipientType attribute?
$cred = Get-Credential
Import-Csv “mailbox.csv” | foreach {
try
{
Set-User $_.Alias `
-LinkedMasterAccount $_.LinkedMasterAccount `
-LinkedDomainController $_.DC `
-LinkedCredential $cred
}
catch
{
Write-Error -Message $_.Exception.Message
}
}