Short post today on how to quickly grab a list of all the User Alerts in a SharePoint Site Collection.
Add-PSSnapin “Microsoft.SharePoint.PowerShell”
$SPSiteCollection = Get-SPSite “http://SiteCollectionName”foreach($SpWeb in $SPSiteCollection.AllWebs)
{
foreach($alert in $SpWeb.Alerts)
{
Write-host “Alert Frequency :” $alert.AlertFrequency
write-host “User: ” $alert.user
Write-Host “Alert List :” $alert.ListUrl
Write-Host “Alert Title :” $alert.title
Write-Host ” ”
}
}
(4870)
0.5
Wondering how you can add an output to a txt or csv filei n thi sscript
Hi John,
I’m certain that there’s better way to get it into the csv, but a quick method would be to just create a new object and Pipe that to a text file.
$SPSiteCollection = Get-SPSite “SiteCollectionURL”
$object = foreach($SpWeb in $SPSiteCollection.AllWebs)
{
foreach($alert in $SpWeb.Alerts)
{
Write-Output “$($alert.AlertFrequency),$($alert.user),$($alert.ListUrl),$($alert.title),”
}
}
$object | Out-file ‘C:\reports\output.txt’ -Append
4
This is not working, tried against Sharepoint on-prem and the alert property doesn’t exist.
Used the new module “SharePointPnPPowerShell2016”.
5