7

If I need to perform a procedure on an Exchange public folder, such as changing permissions, but I don't have the full path to the public folder (which is required in the -identity parameter for most public folder commands), how do I get that full path?

Some resources I have found have suggested using the powershell get-publicfolder -recurse and filtering the results, but in a large organization with thousands of public folders that command can take hours, if it finishes at all.

6

I've run into this a number of times and it's been frustrating. More often than not, I wind up harassing a user who connects to that folder in order to get the full path from them. Once or twice I've just let it go and said "I can't do it without the full path".

But it turns out that get-recipient does not require the full path in order to return a result.

[PS] > Get-Recipient myPublicFolder
Name                                                        RecipientType
----                                                        -------------
myPublicFolder                                              PublicFolder

And get-publicfolder accepts pipeline input. So you can retrieve the parent path of a public folder (such as "\Parent\Path\myPublicFolder") with the following command:

[PS] > Get-Recipient myPublicFolder | Get-PublicFolder | Format-List ParentPath
ParentPath : \Parent\Path

I have tested and this works whether the public folder is mail-enabled or not. If multiple public folders match your get-recipient results, then this pipeline will return the parent path for all of them.

[PS] > Get-Recipient "marketing"
Name                                                        RecipientType
----                                                        -------------
Marketing-1                                                 PublicFolder
Marketing                                                   PublicFolder
Marketing-2                                                 PublicFolder
Marketing-3                                                 PublicFolder

[PS] > Get-Recipient "marketing" | Get-Publicfolder | fl Name,ParentPath
Name       : Marketing-1
ParentPath : \Parent\Path\Marketing
Name       : Marketing
ParentPath : \Parent\Path
Name       : Marketing-2
ParentPath : \Parent\Path\Sales
Name       : Marketing-3
ParentPath : \Parent\Path\Sales\Reports

I thought I'd share, just in case anyone else runs into the same frustration. This works on Exchange 2010.

This does not work in Exchange 2013 or later. As of this writing (Aug 2019), there does not appear to be any other way to easily retrieve the path of a public folder without filtering the get-publicfolder -recurse cmdlet.

  • and mostly for exchange server 2007 – pdwalker Mar 7 '18 at 11:11
  • I'd like to believe that nobody is still using Exchange 2007, but we have one customer who's still on Exchange 2003 so... – Thomas Mar 8 '18 at 15:57
  • This won't work for partial paths that are not mail enabled. Those won't show up in Get-Recipient result. Maybe the behavior changed put the current Get-Recipient help states: This cmdlet returns all mail-enabled objects (for example, mailboxes, mail users, mail contacts, and distribution groups). – Seth Mar 5 at 7:59
  • 1
    @Seth When I wrote this I did test it against non mail-enabled public folders on Exchange 2010 and it returned complete results. I haven't tested this on Exchange 2016, so perhaps the behavior of the cmdlet has changed. I'll try to arrange some time to test and confirm. – Thomas Mar 5 at 16:28
  • 1
    You have "FilterList" instead of "Format-List" – Glenn Sullivan Oct 31 at 19:30
3

In PowerShell:

$mailpf = Get-MailPublicFolder "yourEmailHere"
Get-PublicFolder $mailpf.EntryID
  • Welcome to ServerFault :) As I stated in my comment below to WFBD's answer, the Get-MailPublicFolder cmdlet only works on mail-enabled public folders. – Thomas Feb 1 at 22:07
  • This works to get the public folder object. The advantage is that it's also usable if you're just using a remote PowerShell to work with Exchange rather than having a full console available. – Seth Mar 5 at 7:56
1

It's even more simple if you do this:

Get-MailPublicFolder "PublicFolderName" | Get-PublicFolder

The output will look something like this:

Name                                                        Parent Path
----                                                        -----------
PublicFolderName                                            \ParentFolderName
  • From technet: "Use the Get-MailPublicFolder cmdlet to retrieve mail-related information about mail-enabled public folders." So this answer would only work for mail-enabled public folders. – Thomas Mar 8 '18 at 15:55
0

Use this

Get-PublicFolder -Recurse -ResultSize unlimited | where name -match "publicfoldername"

  • The down side to this is that where-object is client-side filtering that can take a LONG time when you have a large org with a lot of public folders. You should filter your result set as far left in the pipeline as possible. – Thomas Feb 1 at 22:04
0

It's not working for me. For me it's working when I use this command:

Get-PublicFolder -Recurse | where {($_.MailEnabled -eq $True)}
  • What isn't working for you? There are already a few other answers. – RalfFriedl Apr 15 at 16:44
  • It looks like Geco is specifically trying to get only those public folders that are mail enabled. The cmdlet get-mailpublicfolder will work for that. – Thomas Apr 19 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.