Skip to main content

Posts

Showing posts from May, 2015

PowerShell to continue from catch block if there is an error

Below code snippet will help you to continue from catch block if there is error, try{ [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")| Out-Null $Site = new-Object Microsoft.SharePoint.SPSite($siteCollUrl) $alertResultsCollection = @() $a = $ErrorActionPreference  $ErrorActionPreference = "SilentlyContinue" foreach($SiteColl in $Site.WebApplication.Sites) { if($SiteColl -ne $null) { Write-Host "Processing site " $SiteColl.URL Try{                 foreach ($web in $SiteColl.AllWebs)  { if($web -ne $null) { Try{ foreach ($alert in $web.Alerts) {                                             $alertURL = $web.URL + "/" $alertResult = New-Object PSObject $alertResult | Add-Member -type NoteProperty -name "List_URL" -value $alertURL $alertResult | Add-Member -type NoteProperty -name "Alert_Title&quo