In this article, I am going to write powershell script to find all mail enabled lists and libraries in SharePoint server. The following powershell script export all the mail enabled lists from a SharePoint web application to csv file. You need to replace your own web application url in the below script.
Add-PSSnapin Microsoft.SharePoint.PowerShell $SPWebApp = Get-SPWebApplication "http://MySharePointWeb.com/" # get all the site collections $SiteCollections = $SPwebApp.Sites $SiteCollections | ForEach-Object { # get the all sub sites of site collection $SubSites = $_.AllWebs $SubSites | ForEach-Object { $Site = $_ # get all lists from site $lists = $Site.Lists | Where-Object { $_.BaseType -eq 'GenericList' } $lists | ForEach-Object { if (($_.CanReceiveEmail) -and ($_.EmailAlias) ) { New-Object -TypeName PSObject -Property @{ ListName = $_.Title SiteUrl = $Site.Url EmailAlias = $_.EmailAlias }}}}}| Export-CSV "C:\All-Mail-Enabled-Lists.csv" -NoTypeInformation -Encoding UTF8
Get all Mail Enabled Document Libraries in a SharePoint web application
The below powershell script find and export all the incoming e-mail enabled document libraries from a SharePoint web application to csv file.
Add-PSSnapin Microsoft.SharePoint.PowerShell $SPWebApp = Get-SPWebApplication "http://MySharePointWeb.com/" # get all the site collections $SiteCollections = $SPwebApp.Sites $SiteCollections | ForEach-Object { # get the all sub sites of site collection $SubSites = $_.AllWebs $SubSites | ForEach-Object { $Site = $_ # get all document Libraries from site $lists = $Site.Lists | Where-Object { $_.BaseType -eq 'DocumentLibrary' } $lists | ForEach-Object { if (($_.CanReceiveEmail) -and ($_.EmailAlias) ) { New-Object -TypeName PSObject -Property @{ ListName = $_.Title SiteUrl = $Site.Url EmailAlias = $_.EmailAlias }}}}}| Export-CSV "C:\All-Mail-Enabled-Libraries.csv" -NoTypeInformation -Encoding UTF8
Advertisement
Couldn’t you change line 12 to get all incoming email targets by changing it to
$lists = $Site.Lists | Where-Object { ($_.BaseType -eq ‘DocumentLibrary’) -or ($_.BaseType -eq ‘GenericList’) }
Sure we can do it.