Sunday, October 6, 2019

User Alerts on Lists/Libraries in SharePoint site collection using PowerShell

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$output = "C:\useralerts.csv";
$SPSiteCollection = Get-SPSite “http://2010.ajtech.com”
$alertcount=0
$test = " "
foreach($SpWeb in $SPSiteCollection.AllWebs)
{
foreach($alert in $SpWeb.Alerts)
{
$alertcount += 1

$alert.AlertFrequency | Out-File -Encoding Default -Append -FilePath $Output;
$alert.user.userlogin | Out-File -Encoding Default -Append -FilePath $Output;
$spweb.url | Out-File -Encoding Default -Append -FilePath $Output;
$alert.ListUrl | Out-File -Encoding Default -Append -FilePath $Output;
$alert.Title | Out-File -Encoding Default -Append -FilePath $Output;
$test | Out-File -Encoding Default -Append -FilePath $Output;

}
}

"alert count is :" + $alertcount | Out-File -Encoding Default -Append -FilePath $Output

No comments:

Post a Comment