<#
******-----------------------------------------------------------------------******
Author -> Shiv Mangal Singh
Date -> 16 th August - 2017
Description ->
# 1. Fetches Incoming Emails configured in any lists/libraries in entire site collection.
# 2. Input file(.csv) and output file(.csv) location should be updated in the script
# 2. Exports all the data to CSV files
#
******-----------------------------------------------------------------------******
#>
Add-PSSnapin microsoft.sharepoint.powershell
function GetEmailNotificationInfo([String]$sitecoll)
{
$listarray=@()
$sitecollection=Get-SPSite -Identity $sitecoll
foreach($site in $sitecollection.AllWebs)
{
Write-Host "Current Subsite- " $site
foreach($splist in $site.Lists)
{
if($splist.CanReceiveEmail -and $splist.EmailAlias)
{
Write-Host "Incoming Email configured " $splist.CanReceiveEmail " + List Name- " $splist.title-ForegroundColor Green
$obj=New-Object PSObject
$obj | Add-Member -MemberType NoteProperty -Name "ListName" -Value $splist.Title
$obj | Add-Member -MemberType NoteProperty -Name "Site Url" -Value $splist.ParentWeb.Url.ToString()
$obj | Add-Member -MemberType NoteProperty -Name "Subsite Url" -Value $site.Url
$obj | Add-Member -MemberType NoteProperty -Name "can Receive Email" -Value "True"
$obj | Add-Member -MemberType NoteProperty -Name "Email Address" -Value $splist.EmailAlias
$listarray+=$obj
}
}
#change the export path as required #
}
$listarray | Out-File -filepath "D:\contosoSPSSU_MW_Team\shiv\CheckIncomingEmailsInSiteCollection\IncomingEmailsReport.Csv" -Append
#$listarray | Export-Csv -Path "D:\contosoSPSSU_MWTeam\Shiv\Test.Csv" -Append
}
# please change the sitecollection url as per need #
#$sitecoll="http://w15-sp/sites/prasad"
# Calling the function with passing site collection url as parameter to function #
$textfile = "D:\contosoSPSSU_MW_Team\shiv\CheckIncomingEmailsInSiteCollection\Siteowners.csv"
ForEach ($sitecoll in Get-Content $textfile)
{
Write-Host "Current Site- " $sitecoll -ForegroundColor DarkYellow
GetEmailNotificationInfo($sitecoll)
}
******-----------------------------------------------------------------------******
Author -> Shiv Mangal Singh
Date -> 16 th August - 2017
Description ->
# 1. Fetches Incoming Emails configured in any lists/libraries in entire site collection.
# 2. Input file(.csv) and output file(.csv) location should be updated in the script
# 2. Exports all the data to CSV files
#
******-----------------------------------------------------------------------******
#>
Add-PSSnapin microsoft.sharepoint.powershell
function GetEmailNotificationInfo([String]$sitecoll)
{
$listarray=@()
$sitecollection=Get-SPSite -Identity $sitecoll
foreach($site in $sitecollection.AllWebs)
{
Write-Host "Current Subsite- " $site
foreach($splist in $site.Lists)
{
if($splist.CanReceiveEmail -and $splist.EmailAlias)
{
Write-Host "Incoming Email configured " $splist.CanReceiveEmail " + List Name- " $splist.title-ForegroundColor Green
$obj=New-Object PSObject
$obj | Add-Member -MemberType NoteProperty -Name "ListName" -Value $splist.Title
$obj | Add-Member -MemberType NoteProperty -Name "Site Url" -Value $splist.ParentWeb.Url.ToString()
$obj | Add-Member -MemberType NoteProperty -Name "Subsite Url" -Value $site.Url
$obj | Add-Member -MemberType NoteProperty -Name "can Receive Email" -Value "True"
$obj | Add-Member -MemberType NoteProperty -Name "Email Address" -Value $splist.EmailAlias
$listarray+=$obj
}
}
#change the export path as required #
}
$listarray | Out-File -filepath "D:\contosoSPSSU_MW_Team\shiv\CheckIncomingEmailsInSiteCollection\IncomingEmailsReport.Csv" -Append
#$listarray | Export-Csv -Path "D:\contosoSPSSU_MWTeam\Shiv\Test.Csv" -Append
}
# please change the sitecollection url as per need #
#$sitecoll="http://w15-sp/sites/prasad"
# Calling the function with passing site collection url as parameter to function #
$textfile = "D:\contosoSPSSU_MW_Team\shiv\CheckIncomingEmailsInSiteCollection\Siteowners.csv"
ForEach ($sitecoll in Get-Content $textfile)
{
Write-Host "Current Site- " $sitecoll -ForegroundColor DarkYellow
GetEmailNotificationInfo($sitecoll)
}
No comments:
Post a Comment