Categories
Administration Exchange Server 2007 Exchange Shell Linux Windows

Exchange Server 2007: Bulk mailbox-enabling users using Exchange Shell

Bulk mailbox-enabling users using the Exchange console

In Exchange Server 2007 SP1, the Exchange console (EMC) allows you to create mailboxes for existing users. When selecting an existing user in the New Mailbox wizard, you can select multiple users by using the regular SHIFT-Click (to select a continuous list of users) and CTRL-click (to pick the users you want).

First we need to find the users without mailboxes. The get-user command will list all users. The RecipientType property of the user is either User or UserMailbox. As the name clearly suggests, those with UserMailbox as RecipientType are already mailbox-enabled – leaving those with RecipientType User.

You can enable all users with RecipientType User:

get-user | where-object{$_.RecipientType –eq “User”}

Yes, that may not be a great idea! So let’s filter these users. If these users reside in a particular Organizational Unit, we can restrict our search to that OU. In this case, we’ll look for users in the OU called “People”:

get-user –organizationalUnit people | where-object{$_.RecipientType –eq “User”}

Now we get a list of all users (who are not mailbox-enabled) from that OU. We can further restrict this list to all users who are members of a particular department. Since Sales is our favorite department, let’s pick Sales:

get-user –organizationalUnit people | where-object{$_.RecipientType –eq “User” -and $_.department –eq “Sales”}

Now we’ve got a smaller list of folks – those residing in the People OU belonging to Sales dept. and aren’t mailbox-enabled yet. Let’s go ahead and mailbox-enable these users:

get-user –organizationalUnit people | where-object {$_.RecipientType –eq “User” -and $_.department –eq “Sales”} | Enable-Mailbox –Database “EXCHANGE1Mailbox Database” | get-mailbox | select name,windowsemailaddress,database

The above command mailbox-enables these users and outputs a list of their names, default email address, and the mailbox Store on which their mailbox(es) reside.

Similarly, you can also use other user attributes of user accounts like city, state, country, etc. to selectively mailbox-enable users.

PowerShell / Exchange shell does to VBS scripts what scripting did to repetitive GUI tasks.

Categories
Administration CLI Command Line Exchange Server 2007 Exchange Shell Linux Windows Windows 2000 Windows 2003

Exchange 2007 HOW TO: Add Email Addresses To Public Folders

How do we add email addresses to Public Folders?

It should be pretty simple – If Get-Mailbox shows the emailaddresses property for a mailbox, and Set-Mailbox allows you to use the -EmailAddresses switch to add email addresses, one can’t be blamed for believing it’ll work the same way for Public Folders.

Objects other than Public Folders need to be mailbox or mail-enabled to be Exchange recipients, Public Folders do not (Yes, they are mail-enabled by default). To modify mail-related attributes of Public Folders, you use the Set-MailPublicFolder command.

To add additional email address to a (mail-enabled) Public Folder:

$PF = Get-MailPublicFolder “Sales”

$PF.EmailAddresses += “Sales-EMEA@domain.com”

$PF | Set-MailPublicFolder

The first line gets mail-related properties of Public Folder “Sales” in a variable called $PF. Next, we add the additional email address, without wiping out the existing ones. Finally, we commit the change using Set-MailPublicFolder.

If you simply use Set-MailPublicFolder “Sales” -EmailAddresses “Sales-EMEA@domain.com”, it will replace the existing values in the EmailAddresses property.

Another difference to note between how the Set-PublicFolder and Get-PublicFolder commands work, compared to Set-MailPublicFolder and Get-MailPublicFolder – the former takes a relative path of a Public Folder. For instance, to get the Sales PF if it’s in the root of the Public Folder tree, we would need to add a before the name:

Get-PublicFolder Sales

However, the Get/Set-MailPublicFolder commands work using the alias/display name of the PF. Why the difference? One way to look at it – when using Get/Set-PublicFolder, you’re working with the actual Public Folder. When using Get/Set-MailPublicFolder, you’re working with the Active Directory object created for that Public Folder (which holds mail-related attributes, making it possible for a Public Folder to be mail-enabled).

To change the primary email address of the Public Folder “Sales” from “Sales@domain.com” to the new address we just entered – “Sales-EMEA@domain.com”:

Set-MailPublicFolder “Sales” -EmailAddressPolicyEnabled $false -PrimarySmtpAddress “Sales-EMEA@domain.com”

As you may have already figured out, we exempted the Public Folder from getting EmailAddressPolicies applied. In Exchange Server 2003/2000, you could change the default email address of a recipient, without unchecking the checkbox. Result: A few minutes after you completed the change, Recipient Policies would apply and change the primary email address back.

Exchange Server 2007 doesn’t let you change the default email address without exempting the recipient from email address policies.