Tuesday, October 1, 2013

Change the Alert frequency for a particular User

שלום חברים,
היום נתבקשתי למצוא דרך לשנות למשתמש מסויים את תדירות ההתראות שהוא מקבל למייל האישי שלו, מתדירות יומית לתדירות חודשית.
ניסתי למצוא דרך לשנות את ההגדרת דרך ממש המשתמש של SharePoint אך ללא הצלחה.
הפתרון שמצאתי הגיע בעזרת קוד PowerShell פשוט.
להלן הקוד :
$web = Get-SPWeb "http://pais-portal/sites/operation/" #Modify with your URL
$listurl = "Lists/List Name" #Modify to the relative URL of your list

foreach($alert in $web.Alerts)
{
    if($alert.ListUrl -eq $ListUrl)
    {          
            "User : " + $alert.User.Name
            "Title : " + $alert.Title
            "Frequency : " + $alert.AlertFrequency
            "Delivery Via : " + $alert.DeliveryChannels
            "Change Type : " + $alert.eventtype
            Write-Host "=================================="

            # Cange the Frequency for a User
                if($alert.User.UserLogin -eq 'Domain\User Account')
                        {
                          $alert.AlertFrequency = "Daily"   # You can put this values : Immediate/Daily/Weekly
                          $alert.Update()
                        }
    }
}


<# if somthing goes wrorng cahnge the rows to :
   $alert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Daily
   $alert.Update() #>


בהצלחה !
רון נס.


============================================================================================================================================================================================================================================================




Hello Friends,
Today I was asked to find a way to change the frequency of the alert to a particular user, he is getting the alert to his email every day and he want to get the alerts every  month.
I tried to find a way to change the settings through SharePoint UI but without success.
The solution I found was using a simple PowerShell code.
Here's the code:
$web = Get-SPWeb "http://pais-portal/sites/operation/" #Modify with your URL
$listurl = "Lists/List Name" #Modify to the relative URL of your list

foreach($alert in $web.Alerts)
{
    if($alert.ListUrl -eq $ListUrl)
    {          
            "User : " + $alert.User.Name
            "Title : " + $alert.Title
            "Frequency : " + $alert.AlertFrequency
            "Delivery Via : " + $alert.DeliveryChannels
            "Change Type : " + $alert.eventtype
            Write-Host "=================================="

            # Cange the Frequency for a User
                if($alert.User.UserLogin -eq 'Domain\User Account')
                        {
                          $alert.AlertFrequency = "Daily"   # You can put this values : Immediate/Daily/Weekly
                          $alert.Update()
                        }
    }
}


<# if somthing goes wrorng cahnge the rows to :
   $alert.AlertFrequency = [Microsoft.SharePoint.SPAlertFrequency]::Daily
   $alert.Update() #>

Good luck :)
Ron Ness.

No comments:

Post a Comment