locked
Getting List of all the alerts setup for Doc Lib in MOSS using PowerShell RRS feed

  • Question

  • Hi Everyone,

    Recently i got a requirement from user : regarding getting list of all the alerts for users that are setup on doc library .  Well i think in MOSS there is no such out of box functionality for that could help me .One of friends told me to use PowerShell to get the info . Am new to powershell , i worte below script but its not giving results . Can somebody please help me with this:

    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    $Site=new-Object Microsoft.SharePoint.SPSite("http://test-teams.abc.com/")
    $LibURL = "Shared Documents" 
    foreach($alert in $Site.Alerts)
    {
        if($alert.ListUrl -eq $LibUrl)
        {          
                "user name    - " + $alert.User.Name
                "title        - " + $alert.Title
                "Frequency    - " + $alert.AlertFrequency
                "change type  - " + $alert.eventtype
                Write-Host "===================="
        }
    }

    Environment : MOSS SP3 , PowerShell 1.0

    Thanks in advance..

    Regards

    Karan

    Thursday, March 14, 2013 10:11 PM

Answers

  • The Alerts property is a property of an SPWeb (i.e. a site), not an SPSite (i.e. a site collection).

    In other words, your second line should be changed to retrieve the SPWeb at http://test-teams.abc.com rather than the site collection. Alternatively you could iterate through $Site.RootWeb.Alerts in line 4.

    You may still not get results but hopefully this gets you closer to your goal.


    Jason Warren
    Infrastructure Architect

    • Marked as answer by karansharma Friday, March 15, 2013 7:02 AM
    Friday, March 15, 2013 1:01 AM

All replies

  • The Alerts property is a property of an SPWeb (i.e. a site), not an SPSite (i.e. a site collection).

    In other words, your second line should be changed to retrieve the SPWeb at http://test-teams.abc.com rather than the site collection. Alternatively you could iterate through $Site.RootWeb.Alerts in line 4.

    You may still not get results but hopefully this gets you closer to your goal.


    Jason Warren
    Infrastructure Architect

    • Marked as answer by karansharma Friday, March 15, 2013 7:02 AM
    Friday, March 15, 2013 1:01 AM
  • Thanks Jason, it worked :)

    Regrads,

    Karan Sharma

     
    Friday, March 15, 2013 7:03 AM