Today, I will show you how to configure alerts using Powershell. In this article we will be seeing how to create an alert for a particular user subscribed for a document library using powershell.

Here are the steps:

1. Go to Start => All Programs => Microsoft SharePoint 2010 products => SharePoint 2010 Management Shell.

2. Run as an administrator.

3. Run the following script.

$site = Get-SPSite “http://serverName:22222/sites/TestSite/”
$web=$site.Rootweb
$list=$web.Lists.TryGetList(“Shared Documents”)
$user = $web.EnsureUser(‘domainName\userName’)
$newAlert = $user.Alerts.Add()
$newAlert.Title = “My Custom Alert”
$newAlert.AlertType=[Microsoft.SharePoint.SPAlertType]::List
$newAlert.List = $list
$newAlert.DeliveryChannels = [Microsoft.SharePoint.SPAlertDeliveryChannels]::Email
$newAlert.EventType = [Microsoft.SharePoint.SPEventType]::Add
$newAlert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Immediate
$newAlert.Update()

4. Go to Site Actions => Site Settings =>Site Administration => User Alerts.


5. Select the user from the drop down to show all the alerts created by that user and click on “Update”.


Fill your username.

6. A new alert is created successfully using SharePoint object model.

7. An alternative method to check the newly created alert is to go to the Shared Documents (I have mentioned to create an alert for Shared Documents in my code) => in the ribbon interface, select Library Tools => Library => Alert Me.


8. Click on “Manage my alerts”.

9. Done. Here is the image that you should be able to see