Sunday, March 18, 2007

Finding a Public Folder by Email Address

Public folders can be complex and difficult to manage at times. Recently, a colleague identified a public folder in the global address list that was misdirecting his user support questions. The public folder in question was named “Help Desk”. Working for a University there are multiple help desks and IT departments. The name “Help Desk” was confusing to users and causing misdirected support questions. He tried using his Exchange 2003 tools, the Active Directory Users and Computers snap-in, and the PFDAVAdmin tool without finding the public folder in question. Finally, out of frustration, he asked for my help to find the public folder.

Once again PowerShell came to the rescue. Very quickly I was able to find the folder using its email address from the GAL and give him the public folder path he needed to make the necessary changes. Here is how you can do it:

First I set the PowerShell scope to view our entire forest (we have many domains and multiple Exchange administrative groups). This is done by changing the properties of the $AdminSessionADSettings variable. Evan Dodds has a good blog post about $AdminSessionADSettings.

$AdminSessionADSettings.ViewEntireForest = $True


Next I used the Get-MailPublicFolder cmdlet to identify the public folder in question:

Get-MailPublicFolder helpdesk@sub.domain.com


I was able to identify the public folder but I still didn’t know the public folder path so that my colleague could make the necessary changes. I found this by piping the results from my previous command to the Get-PublicFolder cmdlet.

Get-MailPublicFolder helpdesk@sub.domain.com | Get-PublicFolder


Now I could use the ‘ParentPath’ attribute to find the public folder path so that he could make the necessary changes.

[PS] C:\>$AdminSessionADSettings.ViewEntireForest = $True
[PS] C:\>$HelpDeskPF = (Get-MailPublicFolder helpdesk@sub.domain.com | Get-PublicFolder)
[PS] C:\>$HelpDeskPF.ParentPath
\Business College\Resources\Resumes


The help desk folder was located within the 'Resumes' folder??? No wonder he couldn't find it.

--Nick

12 comments:

VA's RHD Hachi Roku said...

This is awesome, recently I was asked to find the path to the PF and the only thing they knew was the SMTP address, and where I'm currently at they have so many PFs....

Long story short, besides the web returning tons of useless vbs scripts and ways to try and search using Outlook etc. this was great a great find!

I love PowerShell more and more each day!

Thanks for saving me tons of time!

Drew Henning said...

Nice article.

I too have 1000's of public folders and often times tickets come in with just the smtp address.

Your article was just what I was looking for.

Anonymous said...

That was absolutely exact what I was looking for, safed me the trouble of searching manually in the PF.

Thanks!

Anonymous said...

Bloody legend mate!

lala said...

Thanks for your post and welcome to check: here
.

Vojin Lekovic said...

Your colleague asked question for Exchange 2003 and you answered with Exchange 2007 cmdlets.

Anonymous said...

Thanks just what I was looking for.

Anonymous said...

Absolutely spot on. 10/10 for clarity, readability, understandability and useability!

Many thanks for that one.

Best Regards

Nitin Arora said...
This comment has been removed by the author.
Anonymous said...

what if the public folder is not mail enabled. is there an easy way to find the path if all you know is the name of the public folder. get-publicfolder | where{$_.name -eq "xxx"} takes forever.

PC Healer said...

I get this error when trying to run the command " The term 'get-mailpublicfolder' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again."

Why is that ?

Unknown said...

Does anyone know how to achieve the same thing using COM?