Wednesday 23 September 2015

Powershell script to get the list of calendar events through out SiteCollection

.ps1 file: 

Note: Server template=106 referst to event items


Add-PsSnapin Microsoft.SharePoint.PowerShell

$site = new-object Microsoft.SharePoint.SPSite(“https://test-dev.com”)

$query = new-object Microsoft.SharePoint.SPSiteDataQuery

$query.ViewFields = “<FieldRef Name=’Title’ />”

$query.Webs = “<Webs Scope=’SiteCollection’ />”

$query.Lists = “<Lists ServerTemplate=’106' Hidden=’false’ />”

$results = new-object System.Data.DataTable

$results = $site.rootweb.GetSiteData($query)

$results.rows.count

foreach($row in $results.rows)

{

Write-host $row.Title

}

Remove-PsSnapin Microsoft.SharePoint.PowerShell

No comments:

Post a Comment