Home > Microsoft Exchange Tips > Exchange Server Administration Tips > Use the Exchange Management Shell Set command to block senders
Exchange Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

EXCHANGE SERVER ADMINISTRATION TIPS

Use the Exchange Management Shell Set command to block senders


Brien Posey
05.19.2008
Rating: --- (out of 5)


Exchange Server tips, tutorials and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


In this tip, Microsoft Exchange expert Brien Posey explains the Set command's role in the Exchange Management Shell (EMS), and how to use it to configure an Exchange 2007 mailbox to block specific senders.

Using the Exchange Management Shell is recommended to write a script that performs configuration tasks automatically or to manipulate settings that aren't exposed through Exchange Server 2007's GUI. Although managing Exchange from the command line can be intimidating, understanding how EMS' command syntax works can alleviate any fears. Once you understand Exchange Management Shell basics, the next step is to learn how to set various parameters using the Set command.

The Set command

Exchange Management Shell commands are entered in a verb-noun format. The verb tells Exchange Server what action you want to perform, and the noun tells Exchange on what object you want to perform that action. When you need to assign a value to an individual property, use the Set verb. However, the Set command doesn't do anything on its own; it must be paired with a noun.

It's helpful to know which command you will use to accomplish a specific task, but it's not required. Exchange Server offers some help with this, if you know where to look. Because the Set command is commonly used to assign a value to a specific attribute, one way to get help determining which command to use is to enter Get-Help Set-*.

This command instructs Exchange Server 2007 to show you all commands that are valid when used in conjunction with the Set verb. While this results in a long list of commands, it gives you a starting point by listing the name of each command and a brief synopsis of what it does.

If none of the commands listed describe what you want to accomplish, you may want to take another look at the big picture. For example, if you wanted to configure Exchange to reject messages from certain recipients, there isn't a Set command that does this specifically. Messages often are accepted or rejected as they pass through the recipient filter. If you look again at the list of available commands, you'll see the Set-RecipientFilterConfig command.

The ability to block specific recipients is a function of the Set-RecipientFilterConfig command. To block specific recipients, you must know how to use the various parameters associated with this command. Exchange Server will list valid commands and explanations of command actions, but it doesn't give you the command's full syntax. Fortunately, you can append the Set-RecipientFilterConfig command to the Get-Help command, prompting Exchange to display the command's full syntax. The full command for this is:

Get-Help Set-Mailbox

This command gives the full syntax for the Set-Mailbox command, which can be fairly long. However, the syntax that's displayed shows you how to configure a mailbox to block messages from a particular recipient.

After viewing the command's full syntax, you should be able to block the recipients. For example, if you wanted to block the user Brien@contoso.com, the command would be:

Set-RecipientFilterConfig –BlockedRecipients "Brien@contoso.com"

To verify that the command has worked, enter a variation that uses Get instead of Set:

Get-RecipientFilterConfig

The name of the recipient that you entered should appear on the list of blocked recipients.

We used the Set command to associate a value with a property. While working with the Exchange Management Shell, you'll typically use this same technique, even if the value you're setting is unrelated to recipient filtering.

Standard and multi-valued properties

Exchange Server 2007 allows for two different types of properties: standard and multi-valued. A standard property involves assigning a value to an attribute. A multi-valued property is an attribute that can have several values associated with it.

The BlockedRecipients parameter is a multi-valued property, because the list of blocked recipients must be able to store more than one recipient's email address.

With multi-valued properties, you cannot use the Set command as we did previously to add another value. If I wanted to add Posey@contoso.com to the list of blocked recipients, for example, I would enter:

Set-RecipientFilterConfig –BlockedRecipients "Posey@contoso.com"

More Exchange Management Shell resources:
How to use Exchange Management Shell's Filter command

Control query results with Exchange Management Shell's Format command

How to test Exchange Management Shell commands

The Exchange Management Shell for Exchange Server 2007

When I enter the Get-RecipientFilterConfig command, the first blocked recipient's email address has been overwritten. To compile a list of values for the property, use the variables. The basic idea is to define a variable, and then use the Get command to populate the variable. You then can use the Set command to add an additional value to the variable.

In Exchange Server 2007, variables are defined with a dollar sign. A variable named List would be called $List. To assign the contents of the RecipientFilterConfig to a variable named List, use this command:

$List = Get-RecipientFilterConfig

Suppose that you wanted to add the email address BP@contoso.com to the list of blocked recipients. First, you must manipulate the variable to contain the new name. The following command adds the new email address to the list of email addresses currently associated with the variable:

$List.BlockedRecipients += "BP@contoso.com"

Keep in mind that we haven't updated the blocked recipients list; we've only updated the variable. We must now update the blocked recipients list with the variable's contents. To do so, use the Set command as shown here:

Set-RecipientFilterConfig –BlockedRecipients $List.BlockedRecipients

Now we can use the Get-RecipientFilterConfig command to verify that the operation was performed successfully. When entering this command, the Blocked Recipients list should show multiple entries. Figure 1 shows these commands.

Exchange Management Shell Set command Figure 1. Screen showing an assigned multi-valued property. (Click on image for enlarged view.)

About the author: Brien M. Posey, MCSE, has previously received Microsoft's MVP award for Microsoft Exchange, Windows Server and Internet Information Server (IIS). Brien has served as CIO for a nationwide chain of hospitals and was once responsible for the Department of Information Management at Fort Knox. As a freelance technical writer, Brien has written for Microsoft, TechTarget, CNET, ZDNet, MSD2D, Relevant Technologies and other technology companies. You can visit Brien's personal website at www.brienposey.com.

Do you have comments on this tip? Let us know.

Please let others know how useful this tip was via the rating scale below. Do you know a helpful Exchange Server, Microsoft Outlook or SharePoint tip, timesaver or workaround? Email the editors to talk about writing for SearchExchange.com.

Rate this Tip
To rate tips, you must be a member of SearchExchange.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Microsoft Exchange Server Scripts and Programming
EMS add-on tool generates graphical Exchange Server 2007 reports
A primer on the Exchange Server 2007 Exchange Management Shell
How to generate HTML reports with the Exchange Management Shell (EMS)
How to test Exchange Management Shell commands
Grant or deny permissions to access a user's Exchange 2007 mailbox
Control query results with Exchange Management Shell's Format command
How to use Exchange Management Shell's Filter command
How to use the Exchange Management Shell command syntax
Fix OWA message size limit issue after Exchange 2007 SP1 upgrade
Automatically save Microsoft Outlook email attachments to disk

Microsoft Exchange Server 2007
Virtualizing Exchange Server 2007 with Microsoft's Hyper-V
Configure Microsoft SharePoint mobile access via Exchange Server 2007
Troubleshoot Outlook 2007 error 0X8004010F on Exchange Server 2007
How to export Global Address List data to Microsoft Office Access
Create a group policy to prevent .PST file storage in Exchange 2007
Synchronizing the Windows Mobile emulator with Exchange Server 2007
Considerations for virtualizing an Exchange Server environment
EMS add-on tool generates graphical Exchange Server 2007 reports
Third-party Exchange Server 2007 backup and restore tools
A primer on the Exchange Server 2007 Exchange Management Shell
Microsoft Exchange Server 2007 Research

Microsoft Exchange Server Mailbox Management
How to verify Exchange Server email forwarding
Uncovering Microsoft Outlook 2007's hidden diagnostic tools
How to keep a copy of migrated Exchange mailboxes on original server
Monitor mail flow with the Exchange Server 2007 Queue Viewer tool
Migrating resource mailboxes from Exchange 2003 to Exchange 2007
Methods for moving mailboxes and public folders to Exchange 2007
Email archiving and retention with Exchange 2007 managed folders
Install the Outlook Connector to use Hotmail in Microsoft Outlook
Reconfigure an existing Exchange Server user account for a new user
Create Exchange user and mailbox accounts on a Windows 2000 PDC

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
application program interface  (SearchExchange.com)
event sink  (SearchExchange.com)
synchronous groupware  (SearchExchange.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2004 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts