I came across a script by Jess Collicott for finding alerts in a SharePoint 2010 site collection. I modified the script slightly so that it can find all alerts in a web application.
Add-PSSnapin microsoft.sharepoint.powershell
$alertResultsCollection = @()
$webapp = Get-SPWebApplication http://<URL of your web application>
foreach ($site in $webapp.Sites)
{
Write-Host "Processing site " $site.URL
foreach($web in $site.AllWebs)
{
foreach($alert in $web.Alerts)
{
$alertURL = $web.URL +"/"
$alertResult = New-Object PSObject
$alertResult | Add-Member -type NoteProperty -name "List URL" -value $alertURL
$alertResult | Add-Member -type NoteProperty -name "Alert Title" -value $alert.Title
$alertResult | Add-Member -type NoteProperty -name "Alert Type" -value $alert.AlertType
$alertResult | Add-Member -type NoteProperty -name "User ID" -value $alert.User
$alertResult | Add-Member -type NoteProperty -name "User Name" -value $alert.User.Name
$alertResultsCollection += $alertResult
}
}
}
$webapp.Dispose()
$alertResultsCollection | Export-CSV "C:\Alerts.csv"
$alertResultsCollection = null
You can save this script with a PS1 file e.g.; GetSPUSerAlerts.PS1 and execute it by issuing the following command in command prompt:
PowerShell -file C:\GetSPUserAlerts.ps1
No comments:
Post a Comment