Date and Month display

Get alerts at Site Collection level using PowerShell

<#
******-----------------------------------------------------------------------******
Author          -> Shiv Mangal Singh
Date            -> 1st Feb - 2017
Description     -> This Script will Find all Alerts at Site Collection level in SharePoint 2013

Path of csv file->$path = "D:\contosos SPSSU_MWTeam\Shiv\ps\alert.csv"
Site Collection Name --> $site = Get-SPSite "https://ms.contactd.contosos.net/cmm/ecm"

******-----------------------------------------------------------------------******
 #>
Add-PSSnapin "Microsoft.SharePoint.Powershell"
$site = Get-SPSite "https://ms.contactd.contosos.net/cmm/ecm"
# Declare an array to hold the all alert
$alertlistCollection =@()
$path = "D:\contosos SPSSU_MWTeam\Shiv\ps\alert3.csv"
# Iterate foreach loop for each sub sites
foreach($Web in $site.AllWebs)
{
#Iterate through each alert in Web[Site]
foreach($alert in $Web.Alerts)
{
$alertUrl =$Web.Url +"/"+ $alert.ListUrls
#$alertUrl--> Create an object and assign the values.
$alertResult = New-Object PSObject
$alertResult | Add-Member -MemberType NoteProperty -Name "List Url" -Value $alertUrl
$alertResult | Add-Member -MemberType NoteProperty -Name "Alert Title " -Value $alert.Title
$alertResult | Add-Member -MemberType NoteProperty -Name "Alert Type" -Value $alert.AlertType
$alertResult | Add-Member -MemberType NoteProperty -Name "Subscribed User" -Value $alert.User
# $alertlistCollection varibal to holding all alert.
$alertlistCollection +=$alertResult
Write-Host $alertlistCollection
}
}
$Web.Dispose()

# Export to CSV
$alertlistCollection | Export-Csv $path

No comments:

Post a Comment