When you migrate list or site, the user alerts in the site will not be migrated together with the content. Below content can help you to do this task. But please take care of it, if you operate it on Prod environment.

Enable or disable alerts for Web application

## To enable alerts for Web application

$SPwebapp=Get-SPWebApplication "http://SharePointSite.com"

$SPwebapp.AlertsEnabled = $true

$SPwebapp.Update()

# To Disable alerts for a Web application

$SPwebapp.AlertsEnabled = $false

$SPwebapp.Update()

Create Alert in SharePoint using PowerShell

##### Create an New alert for an user #########

$SPsite = Get-SPSite "http://SharePointSite.com"

$SPweb=$SPsite.Rootweb

$SPlist=$SPweb.lists["Shared documents"]

$SPuser = $SPweb.EnsureUser('Domain\Salaudeen')

$SPnewAlert = $SPuser.Alerts.Add()

$SPnewAlert.Title = "My Custom Alert"

$SPnewAlert.AlertType=[Microsoft.SharePoint.SPAlertType]::List

$SPnewAlert.List = $SPlist

$SPnewAlert.DeliveryChannels = [Microsoft.SharePoint.SPAlertDeliveryChannels]::Email

$SPnewAlert.EventType = [Microsoft.SharePoint.SPEventType]::Add

$SPnewAlert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Immediate

$SPnewAlert.Update()

$SPweb.Dispose()

$SPSite.Dispose()

Get all Alerts for an user in SharePoint with PowerShell

##### Display All alerts for a Particular List ########

$SPWeb = Get-SPWeb "http://SharePointSite.com"

#Relative URL of list/document library. For lists "Lists/Tasks"

$SPListURL = "Shared Documents" 

foreach($alert in $SPWeb.Alerts)

{

    if($alert.ListUrl -eq $SPListUrl)

    {           

            "User Name    - " + $alert.User.Name

            "Title        - " + $alert.Title

            "Frequency    - " + $alert.AlertFrequency

            "Delivery Via - " + $alert.DeliveryChannels

            "Change Type  - " + $alert.eventtype

            Write-Host "=================================="

    }

}

$SPweb.Dispose()

Create Alerts for All users in a Group

##### Set alerts for all users in the SharePoint Group ######

$SPweb = Get-SPWeb "http://SharePointSite.com"

$SPgroup = $SPweb.Groups["SharePoint Owners"]

$SPlist = $SPweb.Lists["Shared Documents"]

foreach ($SPuser in $SPgroup.Users){

     $alert = $SPuser.Alerts.Add()

     $alert.Title = "My Alert"

     $alert.AlertType = [Microsoft.SharePoint.SPAlertType]::List

     $alert.List = $SPlist

     $alert.DeliveryChannels = [Microsoft.SharePoint.SPAlertDeliveryChannels]::Email

     $alert.EventType = [Microsoft.SharePoint.SPEventType]::Add

     $alert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Immediate

     $alert.Update()

}

$SPweb.Dispose()

Update SharePoint Alerts using PowerShell

#####  Making Changes in Existing Alerts ########

$SPsite = Get-SPSite "http://SharePointSite.com"

$SPweb=$SPsite.RootWeb

$SPuser=$SPweb.EnsureUser('Domain\Salaudeen')

$SPalertCollection=$SPuser.Alerts

foreach($alert in $SPalertCollection)

{

  $alert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Daily

  $alert.Update()

} 

Get Alerts for a Particular User

##### Get alerts for a particular user #########

$SPsite = Get-SPSite "http://SharePointSite.com"

$SPweb=$SPsite.RootWeb

$SPuser=$SPweb.EnsureUser('Domain\Salaudeen')

$SPalertCollection=$SPuser.Alerts

foreach($alert in $SPalertCollection)

{

 write-host -f Green $alert.Title

}

Find All Alerts of an User in Entire Site collection

##### Get the Alerts of Entire Site collection #####

$SPsiteCollection = Get-SPSite "http://SharePointSite.com"

# Iterate through all Webs in the Site Collection

foreach($SPweb in $SPsiteCollection.AllWebs) 

 {

   foreach($alert in $SPweb.Alerts)

    {

        Write-Host "Alerts List :" $alert.ListUrl

    Write-Host "Alerts Title :" $alert.title

    write-host "Subscribed User: " $alert.user

     }

 }

Delete All SharePoint alerts from a List using powershell

##### Delete All alerts for a specific List #####

$SPweb = Get-SPWeb "http://SharePointSite.com"

$SPlist = $SPweb.lists["Shared Documents"]

$IDS = ""

foreach($alert in $spweb.alerts)

{

    if($alert.ListID -eq $SPlist.ID)

    {

    $IDS += $alert.ID.tostring() + "|"

    }

    write-host -nonewline "*"

}

write-host "deleting..."

foreach($s in $IDS.Split("|"))

{

write-host -nonewline "*"

$spweb.alerts.delete([GUID]$s)

}

Delete user alerts in SharePoint 2010 with PowerShell

##### Remove all alerts for specific user from a Web Application #####

$SPwebApp = Get-SPWebApplication "http://SharePointSite.com"

$SpecificUser = "Domain\Salaudeen"

foreach ($SPsite in $SPwebApp.Sites)

    {

        # get the collection of webs

        foreach($SPweb in $SPsite.AllWebs)

        {

            $alerts = $SPweb.Alerts

            # if 1 or more alerts for a particular user, Make a note of them by copying their ID to an Array

            if ($alerts.Count -gt 0)

            {

                $myalerts = @()

                foreach ($alert in $alerts)

                {

                if ($alert.User -like $SpecificUser)

                {

                    $myalerts += $alert

                }

            }

            ### now we have alerts for this site, we can delete them

            foreach ($alertdel in $myalerts)

            {

                $alerts.Delete($alertdel.ID)

                write-host $alertdel.ID

            }

        }

    }

}

To delete all alerts:

$SPweb.Alerts| foreach-object {$web.Alerts.Delete($_.Id)}

Filter the alerts for a single list:

#For for e.g. http://SharePoint.com/site/Assets"
$SPweb.Alerts| where-object {$_.ListUrl -like "Assets"}

Find all the Alerts for a specific user across the web:

# ? is the alias for where-object cmdlet
$web.Alerts | ? {$_.UserId -like "Domain\Salaudeen"}

Get all the alerts for a user across the entire site collection:

$site.AllWebs | select -expand Alerts | ? {$_.UserId -like "Domain\Salaudeen"

Export User Alerts

$site = Get-SPSite "http://2013portal"

$alertResultsCollection = @()

foreach ($web in $site.AllWebs) {

foreach ($alert in $web.Alerts){

$alertURL = $web.URL + "/" + $alert.ListUrl

$alertResult = New-Object PSObject

$alertResult |Add-Member -type NoteProperty -name "WebUrl" -Value $web.Url

$alertResult | Add-Member -type NoteProperty -name "ListURL" -value $alertURL

$alertResult | Add-Member -type NoteProperty -name "AlertTitle" -value $alert.Title

$alertResult | Add-Member -type NoteProperty -name "ListUrl" -value $alert.ListUrl

$alertResult | Add-Member -type NoteProperty -name "List" -value $alert.List

$alertResult | Add-Member -type NoteProperty -name "DeliveryChannel" -value $alert.DeliveryChannels

$alertResult | Add-Member -type NoteProperty -name "AlertType" -value $alert.AlertType

$alertResult | Add-Member -type NoteProperty -name "EventType" -value $alert.EventType

$alertResult | Add-Member -type NoteProperty -name "Frequency" -value $alert.AlertFrequency

$alertResult | Add-Member -type NoteProperty -name "AlertTime" -value $alert.AlertTime

$alertResult | Add-Member -type NoteProperty -name "SubscribedUser" -value $alert.User

$alertResultsCollection += $alertResult

}

}

$site.Dispose()

$alertResultsCollection

#Export to CSV

$alertResultsCollection | Export-CSV C:\Users\sp2013_farm_admin\Desktop\Alerts.csv

Import User Alerts

Import-Csv C:\Users\sp2013_farm_admin\Desktop\Alerts.csv |ForEach-Object{

$webUrl=$_.WebUrl

$listTitle=$_.List

$alertTitle=$_.AlertTitle

$subscribedUser=$_.SubscribedUser

$alertType=$_.AlertType

$deliveryChannel=$_.DeliveryChannel

$eventType=$_.EventType

$frequency=$_.Frequency

$web=Get-SPWeb $webUrl

$list=$web.Lists.TryGetList($listTitle)

$user = $web.EnsureUser($subscribedUser)

$newAlert = $user.Alerts.Add()

$newAlert.Title = $alertTitle

$newAlert.AlertType=[Microsoft.SharePoint.SPAlertType]::$alertType

$newAlert.List = $list

$newAlert.DeliveryChannels = [Microsoft.SharePoint.SPAlertDeliveryChannels]::$deliveryChannel

$newAlert.EventType = [Microsoft.SharePoint.SPEventType]::$eventType

$newAlert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::$frequency

if($frequency -ne "Immediate"){

$AlertTime=$_.AlertTime

$newAlert.AlertTime=$AlertTime

}

$newAlert.Update()

} 

How to Operate SharePoint User Alerts with PowerShell的更多相关文章

  1. SharePoint自动化系列——通过PowerShell创建SharePoint Lists

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...

  2. SharePoint自动化系列——通过PowerShell创建SharePoint List Items

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...

  3. SharePoint自动化系列——通过PowerShell创建SharePoint Web

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...

  4. SharePoint自动化系列——通过PowerShell创建SharePoint Site Collection

    通过PowerShell创建SharePoint Site Collection,代码如下: Add-PSSnapin microsoft.sharepoint.powershell function ...

  5. SharePoint自动化系列——通过PowerShell在SharePoint中批量做数据

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ PowerShell是基于.NET的一门脚本语言,对于SharePoint一些日常操作支持的很好. ...

  6. SharePoint 解决方案和功能-PowerShell

    1. 添加解决方案到SharePoint场 Add-SPSolution "c:\newsolution.wsp" 2. 获取场中的解决方案 Get-SPSolution 3. 获 ...

  7. 【SharePoint学习笔记】第2章 SharePoint Windows PowerShell 指南

    快速了解Windows PowerShell     从SharePoint 2010开始支持PowerShell,仍支持stsadm.exe工具:     可以调用.NET对象.COM对象.exe文 ...

  8. SharePoint自动化部署,利用PowerShell 导出/导入AD中的用户

    这几个月一直在帮客户改需求,部署.我已经心力憔悴,经过一段时间的摸索,我对用PowerShell实现自动化部署也有了一些心得,比如说利用PowerShell导出导入AD中的User.在基于ShareP ...

  9. [SharePoint 2010] SharePoint 2010 部署、收回和删除解决方案----STSADM和PowerShell

    STSADM stsadm -o addsolution –filename c:\bin\CustomerSiteSearch.wsp stsadm -o deploysolution –name ...

随机推荐

  1. 实战MEF(2):导出&导入

    上一文中,我们大致明白了,利用MEF框架实现自动扫描并组装扩展组件的思路.本文我们继续前进,从最初的定义公共接口开始,一步步学会如何使用MEF. 在上一文中我们知道,对于每一个实现了公共规范的扩展组件 ...

  2. 解决HubbleDotNet搜索引擎索引数据不全的问题

    HubbleDotnet是国产.NET平台搜索引擎的翘楚,开放源代码,使用方便,不过我一直在非生产环境下使用.官方网页在HubbleDotNet开源全文搜索数据库项目--技术详解. 以前当数据库使用M ...

  3. Android随笔之——Android单元测试

    在实际开发中,开发android软件的过程需要不断地进行测试.所以掌握Android的单元测试是极其重要的.您应该把单元测试作为Android应用开发周期的一部分,精心编写的测试可以在开发早起帮你发现 ...

  4. Ubuntu杂记——Ubuntu下以USB方式连接Android手机调试

    在Ubuntu下进行Android开发,发现自己的手机就算打开USB连接.USB调试还是连不上,一直都是显示??????.百度了很多,发现都是要改“ /etc/udev/rules.d/50-andr ...

  5. Lua 学习笔记(十一)元表与元方法

    在Lua中的每个值都有一套预定义的操作集合.例如可以将数字相加,可以连接字符串,还可以在table中插入一对key-value等.但是我们无法将两个table相加,无法对函数作比较,也无法调用一个字符 ...

  6. 制作动画或小游戏——CreateJS基础类(一)

    前面曾经记录过Canvas的基础知识<让自己也能使用Canvas>,在实际使用中,用封装好的库效率会高点. 使用成熟的库还能对基础知识有更深入的理解,CreateJS是基于HTML5开发的 ...

  7. Android TextView中显示图片

    Android官方给我们提供的Html类下面的fromHtml方法 当你需要转换的HTML代码是带图片的,比如<IMG/>,那么你就需要使用到重载的第二个方法了,这个方法里面有个Image ...

  8. maven全局配置文件settings.xml详解

    概要 settings.xml有什么用? 如果在Eclipse中使用过Maven插件,想必会有这个经验:配置settings.xml文件的路径. settings.xml文件是干什么的,为什么要配置它 ...

  9. .Net语言 APP开发平台——Smobiler学习日志:如何在手机上开发仪表盘控件

    最前面的话:Smobiler是一个在VS环境中使用.Net语言来开发APP的开发平台,也许比Xamarin更方便 一.目标样式 我们要实现上图中的效果,需要如下的操作: 1.从工具栏上的"S ...

  10. HTML5模仿逼真地球自转

    查看效果:http://hovertree.com/texiao/html5/8.htm 给我一个支点,我就可以撬动地球 阿基米德 下载 http://hovertree.com/down/h/ear ...