Share via


Managing Public Folders with the Exchange Management Shell

 

By Andrea Fowler

Hi, I'm a public folder!

Public Folder Cartoon Icon

You may remember me from previous articles, such as Public Folders Get a new Pad in Exchange Server 2007 SP1. Well, a friend recently asked me to appear in this article about so that I could explain how to manage public folders by using just the Exchange Management Shell (aka "the Shell"). At first, I was a little hesitant because all of this information is already in all of the rich Exchange 2007 public folders documentation. But then I thought, "What they heck! Anything for a friend!"

Well, here it is! All my tips and tricks for the day-to-day management of public folders in the Shell. So, step into my office and let's get started.

Public folder cmdlet with cartoon

In This Article

Getting started

Modifying public folder settings

Creating and configuring mail-enabled public folders

Viewing public folder information

Modifying client permissions

Getting Started

Do you need public folders? If you aren't already using public folders, chances are that you don't need them and won't implement them in your organization. Still not sure if you'll use public folders? Check out the Exchange Team blog Updated Exchange Public Folder Guidance.

Note

The content of each blog and its URL are subject to change without notice. The content within each blog is provided "AS IS" with no warranties, and confers no rights. Use of included script samples or code is subject to the terms specified in the Microsoft Terms of Use.

For those of you who want to use public folders, there are three basic steps you'll need to take to get started:

  1. Create the public folder database

  2. Modify public folder database settings

  3. Create public folders

Step 1: Create the public folder database

You can't create new public folders unless you have public folder infrastructure. That means that you need to have a public folder database in place and mounted. When you use the New-PublicFolderDatabase cmdlet to create a public folder database, you basically set only the name and storage group for the new database.

In addition to creating a public folder database, you may decide to create this database in a separate storage group. For more information about how to create a storage group, see How to Create a New Storage Group.

Create and mount a public folder database

  • This command creates a public folder named PFDatabase on the First Storage Group:

    New-PublicFolderDatabase -Name "PFDatabase" -StorageGroup "First Storage Group"
    
  • The new public folder database is created in the dismounted state. This command mounts the database created in the previous step:

    Mount-Database -Identity "PFDatabase"
    

Step 2: Modify public folder database settings

After you create and mount the public folder database, you may need to change some of the public folder settings by using the Set-PublicFolderDatabase cmdlet. Modifying public folder database settings is not a task that you will perform every day—it'll usually just be a one-time task. Here are a few examples of some of the things you can change.

Modify information about a public folder database

  • This command sets the retention settings for the public folder database named PFDatabase that resides on SERVER01:

    Set-PublicFolderDatabase -Identity "Server01\PFDatabase" -DeletedItemRetention 07.00:00:00 -RetainDeletedItemsUntilBackup $true -EventHistoryRetentionPeriod 14.00:00:00 -ItemRetentionPeriod unlimited
    
  • This command sets the storage quota for all public folders in the public folder database named PFDatabase:

    Set-PublicFolderDatabase -Identity PFDatabase -IssueWarningQuota 2000MB -QuotaNotificationSchedule "Sun.3:00 AM-Sun.3:15 AM, Tue.3:00 AM-Tue.3:15 AM, Thu.3:00 AM-Thu.3:15 AM"
    

    By using this command, public folder owners will be notified when their public folders meet the storage quota. For more information, see How to View or Modify Public Folder Settings.

  • This command sets the public folder referral settings:

    Set-PublicFolderDatabase -Identity "Server1\PublicFolderDatabase01" -UseCustomReferralServerList $true -CustomReferralServerList "MBXSERVER01:1","MBXSERVER02:50"
    

    Note

    The CustomReferralServerList parameter accepts an array in the following format: serverID:cost. Separate multiple servers with a comma. For more information, see How to Configure Public Folder Referrals.

Step 3: Create public folders

Now it's time to create your public folders. Just like with the public folder database, there are few options that you can set when creating a public folder. This time you'll use the New-PublicFolder cmdlet. For more information about creating public folders, see How to Create Public Folders.

Create a new public folder

  • This command creates a new public folder in the root of the public folder tree on the closest Mailbox server that has a public folder database. This is because the command doesn't specify a server or a path:

    New-PublicFolder -Name "Legal"
    

    Note

    If you don't specify a server, the cmdlet checks if the local server is an Exchange 2007 Mailbox server that has a public folder database. If it is, the public folder is created locally. If it is not, Exchange finds the closest (by site cost) Exchange 2007 Mailbox server that has a public folder database on which to create the public folder.

  • This command creates a new public folder named Pending in an existing public folder named Legal on the Mailbox server named My Server:

    New-PublicFolder -Name "Pending" -Path \Legal -Server "Server01"
    

Well, in a nutshell, that's how you get started with public folders. Next, I'll show you how to use the Shell to complete your daily public folder tasks.

Modifying Public Folder Settings

Public folders and mail-enabled public folders have entirely different settings. If the public folder is mail-enabled, you'll use the Set-MailPublicFolder cmdlet. If the public folder isn't mail-enabled, you'll use the Set-PublicFolder cmdlet.

This section shows you how to modify settings for public folders that aren't mail-enabled. For details about how to mail-enable public folders, including how to configure their settings, see Creating and Configuring Mail-Enabled Public Folders.

When you use the New-PublicFolder cmdlet to create a public folder, you're limited in how many settings you can specify. So, after you create the public folder, you'll need to use the Set-PublicFolder cmdlet to customize the folder.

Configure the settings of a public folder

  • This command specifies that a public folder can use storage size limits other than the values that are set on the public folder database:

    Set-PublicFolder -Identity "\Legal" -UseDatabaseQuotaDefaults: $False
    

    Note

    The value for the Identity parameter must include the path. For example, if the public folder named Marketing existed under a parent folder named Business, you would provide the following value: "\Business\Marketing"

  • This command specifies that over-storage-quota warnings should be sent when the size of the public folder exceeds 10 megabytes (MB):

    Set-PublicFolder -Identity "\Legal\Pending" -StorageQuota 10MB
    

    Note

    The -StorageQuota parameter cannot be used when the -UseDatabaseQuotaDefaults parameter is set to True.

Creating and Configuring Mail-Enabled Public Folders

Mail-enabling a public folder provides an extra level of functionality to users. In addition to being able to post messages to the folder, users can send e-mail messages to, and sometimes receive e-mail messages from, the folder. Mail-enabled public folders have different settings than regular public folders. Public folders will have an e-mail address just like a regular e-mail account.

When you use the Enable-MailPublicFolder cmdlet, you're limited in how many settings you can specify. You need to use the Set-MailPublicFolder cmdlet to set some of the more complicated settings.

Mail-enable a public folder

  • This command mail-enables the root public folder named Legal:

    Enable-MailPublicFolder -Identity "\Legal"
    
  • This command mail-enables the root public folder named Marketing on a server named Server01:

    Enable-MailPublicFolder -Identity "\Marketing" -Server "Server01"
    
  • This command mail-enables the public folder named Pending (which is a subfolder of the Legal public folder) and hides the public folder from the address list:

    Enable-MailPublicFolder -Identity "\Legal\Pending" -HiddenFromAddressListsEnabled $True
    

Now that your public folder is mail-enabled, you may want to modify some of the settings. Here are a few of the things you can do.

Configure the settings of a mail-enabled public folder

  • This command changes the primary SMTP address of the public folder named Legal to LegalPF@contoso.com:

    Set-MailPublicFolder -Identity "\Legal" -PrimarySmtpAddress LegalPF@contoso.com
    

    Note

    You cannot change the primary SMTP e-mail address if the EmailAddressEnabled parameter is set to True. If EmailAddressEnabled is set to True, the public folder uses the defined e-mail address policy. For more information, see Managing E-Mail Address Policies.

  • This command disables the e-mail address policy of the mail-enabled public folder named Pending:

    Set-MailPublicFolder -Identity "\Legal\Pending" -EmailAddressEnabled $False
    
  • This command assigns a value (string) to the first custom attribute of the mail-enabled public folder named Sales:

    Set-MailPublicFolder -Identity "\Legal" -CustomAttribute1 "Legal Information"
    
  • This command sets a 200 megabyte (MB) size limit for the mail-enabled public folder named Legal, after which the folder can no longer send e-mail messages:

    Set-MailPublicFolder -Identity "\Legal" -SendStorageQuota 200MB
    

Viewing Public Folder Information

To keep a handle on your public folders, you'll want to view information about them from time to time. There are a few commands you can use to view public folder information.

  1. Get-PublicFolder   This cmdlet displays the attributes for all public folders. You can use this cmdlet to view information about both mail-enabled public folders and regular public folders.

  2. Get-MailPublicFolder   This cmdlet displays mail-related information about mail-enabled public folders.

  3. Get-PublicFolderStatistics   This cmdlet displays statistical information about public folders, such as folder size and last logon time.

View information about public folders

  • These commands display information about the root public folder:

    Get-PublicFolder
    

    -or-

    Get-PublicFolder -Identity "\"
    
  • This command displays the names of the root public folder and all the public folders below it in the hierarchy:

    Get-PublicFolder -Recurse | Format-List Name
    

    By default, system folders are not displayed. (For example, system folders are not displayed when you run the command Get-PublicFolder -Recurse | Format-List Name.)

  • This command displays the names of all the system folders (which are not displayed by default):

    Get-PublicFolder -Identity \NON_IPM_SUBTREE -Recurse | Format-List Name 
    
  • This command displays information about the public folder named Legal in the root public folder of the server named Server01:

    Get-PublicFolder -Identity "\Legal" -Server "Server01"
    
  • This command displays information about the public folder named Pending that is contained in the public folder named Legal:

    Get-PublicFolder -Identity "\Legal\Pending"
    
  • This command displays information about the public folder named Legal and all the public folders contained within it:

    Get-PublicFolder -Identity "\Legal" -Recurse
    
  • This command displays information about only the public folders that are contained within the public folder named Legal (but not the parent Legal folder or subfolders of the subfolders):

    Get-PublicFolder -Identity "\Legal" -GetChildren
    
  • This command pipes the output of the Get-PublicFolder cmdlet to the Format-List command and displays only the names of all public folders:

    Get-PublicFolder -Recurse | Format-List Name
    
  • This command displays all public folders in the folder named Legal, but limits the number of results that are returned to 100:

    Get-PublicFolder -Identity "Legal" -Recurse -ResultSize 100 | Format-List Name
    

    Note

    You can use the ResultSize parameter only in combination with the Recurse or GetChildren parameters.

  • This command displays all public folders in the folder named Legal, with no limit on the number of results that are returned:

    Get-PublicFolder -Identity "Legal" -Recurse -ResultSize Unlimited | Format-List Name
    

Although you use the Get-PublicFolder cmdlet to view information about mail-enabled public folders, you'll need to use Get-MailPublicFolder if you want to view mail-related information about mail-enabled public folders. Here's a list of types of information you can view

View mail-related information about mail-enabled public folders

  • This command displays the names of all mail-enabled public folders:

    Get-PublicFolder "\" -Recurse -ResultSize Unlimited | Get-MailPublicFolder -ErrorAction SilentlyContinue | Format-List Name
    

    Note

    Setting the ErrorAction parameter to SilentlyContinue stops errors from displaying when folders that are not mail-enabled are encountered by the command.

  • This command displays the information about a specific mail-enabled public folder in a table format:

    Get-MailPublicFolder -Identity "\Legal" | Format-Table
    
  • This command displays mail-related information about the mail-enabled public folder named Pending that is contained in the folder named Legal:

    Get-MailPublicFolder -Identity "\Legal\Pending"
    
  • This command displays mail-related information about a mail-enabled public folder and connects to the domain controller named Contoso01-DC:

    Get-MailPublicFolder -Identity "\" -DomainController "Contoso01-DC" 
    

View public folder statistics

Viewing the statistics of a public folder allows you to see information such as the display name, creation time, last modified time, and item size.

View public folder statistics

  • This command displays the statistics for a public folder named Pending that is contained in the folder named Legal with a piped command to format the list:

    Get-PublicFolderStatistics -Identity "\Legal\Pending" | fl
    
  • This command displays the name and item size for all the public folders on Server01:

    Get-PublicFolderStatitics -Server "Server01" | Format-List Name,ItemSize
    

Modifying Client Permissions

After you've created your public folders, you'll want to determine who owns, edits, and views the public folders. Before you mess with permissions, you should read Configuring Public Folder Permissions.

You can use the Add-PublicFolderClientPermission cmdlet to add permissions, or you can use scripts to add public folder client permissions. Before you use any of the scripts in the following examples, you should read Scripts for Managing Public Folders in the Exchange Management Shell.

Add client access rights to a public folder

  • This command adds Publishing Editor permissions for the user Kim to access the public folder named West Coast:

    Add-PublicFolderClientPermission -Identity "\Marketing\West Coast" -AccessRights PublishingEditor -User Kim
    
  • This script adds Reviewer permissions for the user David to access the top-level public folder named Sales and all of the public folders contained within the Sales tree:

    AddUsersToPFRecursive.ps1 -TopPublicFolder "\Sales" -User "David" -Permission Reviewer
    

Sometimes, you need to remove a user's permissions to public folders. Here are some examples for getting that done. You can use the Remove-PublicFolderClientPermission cmdlet or a script to remove permissions.

Remove a client user's permissions to access a public folder

  • This command removes the user David's permissions to create items in the public folder named Oregon:

    Remove-PublicFolderClientPermission -Identity "Sales\West Coast\Oregon" -User David -AccessRights CreateItems
    
  • This script removes the user David and replaces him with the user Kim to access items in the public folder Sales and all folders under it:

    ReplaceUserWithUserOnPFRecursive.ps1 -TopPublicFolder "\Sales" -UserOld "David" -UserNew "Kim"
    

But That's Not All…

Well, those are just a few things you can do to manage your public folders in the Shell. Of course, there are many other ways you can use the Shell to manage public folders, but since most aren't every day tasks, they weren't included in this article. I don't want to leave you in suspense, though, so check out these topics if you want to learn more about how you can harness the power of the Exchange Management Shell to manage your public folders:

0f7a70fa-710d-4818-bd8b-1faeafb9cf03 Andrea Fowler - Technical Writer, Microsoft Exchange Server