Tuesday 22 September 2015

Powershell script to get the Users list who subscribed to get alerts to sharepoint blog posts

Add-PsSnapin Microsoft.SharePoint.PowerShell

$SPweb = Get-SPWeb "Enter the url of the SharePoint Blog site"
$SPlist = $SPweb.lists["Posts"]
$countusers = 0
write-host $Count
read-host "Please enter a key to process the request"
 write-host "User Name,Login Name"  
  foreach($alert in $SPweb.Alerts)
    {
$user = [string]$alert.user
$Alertuser = $alert.User

$user = $user.Substring(7)
$pos = $user.IndexOf("\")

$user = $user.Substring($pos+1)
$UserName = $Alertuser.Name


Try
{
   
$SPuser=$SPweb.EnsureUser($user)
write-host "$UserName,$user"
}
Catch
{
   
   Continue
}

$countusers = $countusers + 1


write-host "Total Users count "$countusers

Remove-PsSnapin Microsoft.SharePoint.PowerShell

No comments:

Post a Comment