Friday, March 15, 2013

Find SharePoint Mail-enabled Lists

Imagine the following: A user mail-enabled a SharePoint list, or two, or two hundred, and then disappeared. Maybe they found another job; maybe the left for Mexico; maybe they irritated Joey the Hippo and are keeping company with the fishes. Who knows? Frankly, it doesn't matter, beyond giving me the opportunity to offer literary abuse to you, my dear reader.

You are tasked with finding out where all these emails are going. You don't know, so, you turn to Bing, or Google (you don't use any other search engines, I hope), and find me here. I had the same problem. I also had a lot of mail getting stuck in the SharePoint drop folder, and I wanted to get a handle on why it was there.

Behold!

I call this "Get-SPMailEnabledLists"

############################################################################################################
# The following secion iterates through an entire farm. Two closing loops at the end finish out the        #
# For-Each login here                                                                                      #
############################################################################################################
$Farm = Get-SPWebApplication
Foreach ($WebApplicationname in $Farm)
    {
    $WebApplication = Get-SPWebApplication -identity $WebApplicationname
    $WebAppSites = $WebApplication.Sites
    Foreach ($SiteCollectionUrl in $webappsites)
        {
############################################################################################################
# End farm interative initiation                                                                           #
############################################################################################################
               
        $site = Get-SPSite -identity $SiteCollectionUrl
        foreach($web in $site.allWebs)
            {
            $lists = $web.lists
            ForEach($list in $lists)
                {
                if( ($list.CanReceiveEmail) -and ($list.EmailAlias) )
                    {
                    write-host "Current URL:" $web.Url     
                    write-host "Title of list: " $list.Title
                    write-host "Email of list: " $list.EmailAlias
                    }
                }  
            }
        }
    }

You can wrap the snippet above in a emailer or transcripter-er. Format as you like.

Enjoy.

2 comments: