Alerts in SharePoint is a powerful tool for users but about a nightmare for administrator. It’s not comfortable for administrator to see user subscribes and manage them.

For example, it’s really impossible for administrator to change a subscriber using web interface. May be there are third party tools but if you don’t have them right now and the changes you should do immediately?

I was faced  with such a situation and I decided to use powershell to change a subscriber on SharePoint site changes. My result is below. Of course, you can modify it on your own risk 🙂

#Change subscriber in SharePoint
Remove-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue 
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue   
cls 
$url  = "http://spdev" 
$spweb = Get-SPWeb $url 
        foreach ($alert in $spweb.Alerts) 
        { 
               if($alert.get_User().Name -match "old user Fullname") { 
                       $newuser = Get-SPUser("domain\new-user-login") -Web $url 
                       $alert.User = $newuser 
                       $alert.Update() 
                     } 
       } 

 

Another problem with subscribers was when I updated a test environment and I didn’t want users to receive messages about their subscribes. I wanted just to remove them.  My script is similar with the above one, but has some differences.

 

#Remove subscribes 
Remove-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue 
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue   
cls 
$url  = "http://spdev" 
$spweb = Get-SPWeb $url 
        for ($i= $spweb.Alerts.Count; $i -ge 0; $i--) 
        { 
               $alert = $spweb.Alerts[$i] 
               Write-Host 'Deleting ' $alert.ID 
               $spweb.Alerts.Delete($alert.ID) 
        }