Auflistung aller e-Mail fähigen Listen in der SharePoint-Farm

Es sollen “mal schnell” alle Listen & Bibliotheken aufgelistet werden, für die ein e-Mail Empfang konfiguriert ist? Nichts leichter als das:

<#
.SYNOPSIS
Lists all E-Mail enabled lists
If all is fine here you'll need to check
Resolve-DnsName <your-mail-domain-here> -Type MX #make sure the "right" server is the MX
Get-WindowsFeature smtp-server #make sure InstallState is "installed"
Get-Service SMTPSVC #make sure Status is "running"
.EXAMPLE
Get-SPEmailEnabledLists
Gets all e-Mail enabled lists from all webs in all site collections from all WebApplications. This may be a lot to check: You have been warned.
.EXAMPLE
Get-SPEmailEnabledLists -WebApplication (Get-SPWebApplication http://sp.dev/)
Gets all e-Mail enabled lists from all webs in all site collections of the given WebApplication
.EXAMPLE
Get-SPSite | ?{$_.Url - match "my."} | Get-SPEmailEnabledLists
Gets all e-Mail enabled lists from all webs in the given site collections
.EXAMPLE
Get-SPWeb http://sp.dev/sites/simple/sub | Get-SPEmailEnabledLists
Gets all e-Mail enabled lists from the given web
#>
[CmdletBinding()]
param(
[Parameter(
HelpMessage="restrict search to this web",
ValueFromPipeline=$true)]
[Microsoft.SharePoint.SPWeb[]]$Web,
[Parameter(
HelpMessage="restrict search to this site collection",
ValueFromPipeline=$true)]
[Microsoft.SharePoint.SPSite[]]$Site,
[Parameter(
HelpMessage="restrict search to this webApplication",
ValueFromPipeline=$true)]
[Microsoft.SharePoint.Administration.SPWebApplication[]]$WebApplication
)
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction Inquire | Out-Null
# check incoming mail settings
$serverAddr = "<unconfigured>";
$settings = (Get-SPFarm).Services | ?{ $_.TypeName -match "incoming e-mail" } | select -First 1
if((-not $settings) -or (-not $settings.Enabled)){
$url = "_admin/IncomingEmail.aspx";
$ca = (Get-SPWebApplication -IncludeCentralAdministration) | ?{ $_.IsAdministrationWebApplication } | select -First 1
if($ca) {
$url = $ca.Url + $url;
} else {
$url = "http://<your central admin>/$url";
}
Write-Warning "No incoming email-settings found, or incoming email is deactivated. check $url !"
} else {
$serverAddr = $settings.ServerDisplayAddress;
}
# collect the lists to check
if(-not $Web) {
Write-Verbose "no web given - getting all webs from site";
if(-not $Site) {
Write-Verbose "no site given - getting all sites from webApplication";
if(-not $WebApplication) {
Write-Verbose "no webApplication given - getting all webApplications";
$WebApplication = Get-SPWebApplication;
}
$Site = $WebApplication | % { $_.Sites };
}
$Web = $Site | %{ $_.AllWebs };
}
# check the lists
$lists = $Web | %{ $_.Lists }
Write-Verbose "checking $($lists.Count) lists...";
$lists | %{
if(($_.CanReceiveEmail) -and ($_.EmailAlias)) {
[PSCustomObject]@{
Title = $_.Title;
Url = "$($_.ParentWeb.Url)/$($_.RootFolder.Url)";
EmailAlias = "$($_.EmailAlias)@$serverAddr";
}
}
}

Das Skript kann als Eingabe für Out-GridView oder auch Export-Csv verwendet werden – oder auch nur in der Console betrachtet…
Und so ganz nebenbei prüft das Skript noch ob der e-Mail Empfang in der Farm überhaupt eingerichtet ist..