Posts

Showing posts from January, 2019

Iterate through all SharePoint web-applications, site-collections, websites from PowerShell

Iterate through all SharePoint web-applications, site-collections, websites from PowerShell Please do not forget to comment if this helps. PS : $contentWebAppServices = (Get-SPFarm).services |  ? { $_.typename -eq "Microsoft SharePoint Foundation Web Application"} foreach($webApp in $contentWebAppServices.WebApplications) { try { if ($webApp.Url -ne "If you want to skip something") { write-host "Starting WebApplications : " + $webApp.Url foreach($siteColl in $webApp.Sites) { try { write-host "Starting SiteCollection : " + $siteColl.Url $site = Get-SPSite $siteColl.Url if ($site.Allwebs.Count -gt 0) { foreach($web in $site.Allwebs) { //Code for each web } } } catch [Exception] { write-host "Error in Code for : " $siteColl.Url } } } } catch [Exception] { write-host "Error in Code for : &q