Date and Month display

Delete all alerts at Site Collection level using PowerShell

<#
******-----------------------------------------------------------------------******
Author          -> Shiv Mangal Singh
Date            -> 1st Feb - 2017
Description     -> This Script will delete all alerts at Site Collection level in SharePoint 2013

Path of csv file->$path = "D:\contosoMW_Team\Shiv\27Jan17\UniquePermissions.csv"
Site Collection Name --> $site = Get-SPSite "https://ms.contact.contoso.net/global/sapcoe/"

******-----------------------------------------------------------------------******
 #>
Add-PSSnapin "Microsoft.SharePoint.Powershell"
$site = Get-SPSite "https://ms.contactd.contoso.net/sites/test"
# #Iterate foreach loop for all sub sites
foreach($Web in $site.AllWebs)
{
#Iterate through each alert in Web[Site] and count alerts
foreach($alert in $Web.Alerts.Count)
{
Write-Host $alert
# Iterating for loop till alert count is greater then and equal to zero
for($i=$alert-1;$i -ge 0; $i--)
{
Write-host "Deleteing All alert from Site" $Web.Alerts.Delete($i)
}
}
}

No comments:

Post a Comment