Saturday, October 5, 2019

lists enabled with incoming email settings in SharePoint using PowerShell

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$SPWebApp = Get-SPWebApplication "http://2010.ajtech.com"


#create a CSV file
"E-Mail,List,Site" > "EMail-Enabled_home.csv" #Write the Headers in to a text file
 
foreach ($SPsite in $SPwebApp.Sites)  # get the collection of site collections
{
    foreach($SPweb in $SPsite.AllWebs)  # get the collection of sub sites
        {
            foreach ($SPList in $SPweb.Lists)
                {
                    if ( ($splist.CanReceiveEmail) -and ($SPlist.EmailAlias) )
                        {
                            # WRITE-HOST "E-Mail -" $SPList.EmailAlias "is configured for the list "$SPlist.Title "in "$SPweb.Url
                           $SPlist.Title +" ;" + $SPweb.Url >> EMail-Enabled_home.csv  #append the data
                        }
                }
        }
}

No comments:

Post a Comment