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.

Thomas
  • 868
  • 4
  • 17
  • 35

5 Answers5

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.

Thomas
  • 868
  • 4
  • 17
  • 35
  • and mostly for exchange server 2007 – pdwalker Mar 07 '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 08 '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`](https://docs.microsoft.com/en-us/powershell/module/exchange/users-and-groups/get-recipient?view=exchange-ps) help states: This cmdlet returns all mail-enabled objects (for example, mailboxes, mail users, mail contacts, and distribution groups). – Seth Mar 05 '19 at 07: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 05 '19 at 16:28
  • This does not work as of Exchange 2013. For those using Exchange 2013 or later please see the answer by @mike-garcia . I realize the OP was specifically looking for a solution that works with non-mail-enabled public folders but this question is one of the top searches from Google on this subject so I wanted to clarify this answer for others. – New Guy Aug 20 '19 at 18:29
  • @NewGuy - Mike's answer only works for mail-enabled public folders. I did test the get-recipient cmdlet on Exchange 2013 and it does appear that the behavior of the cmdlet did change between 2010 and 2013, so my original answer is out of date. I'll update the question and answer accordingly. – Thomas Aug 30 '19 at 20:41
  • 1
    You have "FilterList" instead of "Format-List" – Glenn Sullivan Oct 31 '19 at 19:30
  • @GlennSullivan - XD :$ :/ – Thomas Nov 01 '19 at 17:29
5

In PowerShell:

$mailpf = Get-MailPublicFolder "yourEmailHere"
Get-PublicFolder $mailpf.EntryID
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
Mike Garcia
  • 51
  • 1
  • 1
  • 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 01 '19 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 05 '19 at 07: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
Aaron Copley
  • 12,345
  • 5
  • 46
  • 67
WFBD
  • 11
  • 1
  • 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 08 '18 at 15:55
0

Use this

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

Irfan
  • 1
  • 1
  • 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 01 '19 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)}
RalfFriedl
  • 3,008
  • 4
  • 12
  • 17
Geco Mynx
  • 23
  • 5
  • What isn't working for you? There are already a few other answers. – RalfFriedl Apr 15 '19 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 '19 at 22:00