Thursday, October 31, 2013

SharePoint & PowerShell: List all alerts (on document libraries, lists) in a site

As a site collection administrator, I find it extremely tedious to go to Site Actions - Site Settings, click on User Alers, and display alerts one by one. Here's a PowerShell script to get the information needed~!

Let's say you have a subsite with the URL http://sharepoint/subsite1

Launch SharePoint 2010 Management Shell and run this script (copy and paste the following, and save it as .ps1).

## Load the website
     $web = Get-SPWeb "http://sharepoint/subsite1/" 
     $resultSet = @() 
         foreach ($alert in $web.Alerts){ 
             $URL = $web.URL + "/" + $alert.ListUrl 
             $result = New-Object PSObject 
             $result | Add-Member -type NoteProperty -name "Title" -value $alert.Title 
             $result | Add-Member -type NoteProperty -name "URL" -value $URL 
             $result | Add-Member -type NoteProperty -name "Alert Type" -value $alert.AlertType 
             $result | Add-Member -type NoteProperty -name "User" -value $alert.User 
             $resultSet += $result 
        } 

## Best practice: dispose when done
    $web.Dispose() 

## Display the result
    $resultsSet 

## To export the result
    $resultSet | Export-Csv "Output.csv"
Related Posts Plugin for WordPress, Blogger...