Creating users alerts using PowerShell in SharePoint 2010
We had a requirement in SharePoint 2010 to automate the creation of alerts based on SPS group membership. After spending some time searching for solution I have managed to write this code in PowerShell to automate the process. I think it worth sharing with you guys.
Creating users alerts using PowerShell code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| $group = $web.Groups["eblogin members"]$list = $web.Lists["eblogin documents"]foreach ($user in $group.Users){ $alert = $user.Alerts.Add() $alert.Title = "eblogin alerts" $alert.AlertType = [Microsoft.SharePoint.SPAlertType]::List $alert.List = $list $alert.DeliveryChannels = [Microsoft.SharePoint.SPAlertDeliveryChannels]::Email $alert.EventType = [Microsoft.SharePoint.SPEventType]::Add $alert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Immediate $alert.Update()}$web.Dispose() |
You can also change the DeliveryChannels option to SMS and AlertFrequenct option to Daily. You could run different scripts for your different SharePoint groups.
No comments:
Post a Comment