CAML Query in PowerShell
$URL = "yoursiteurl"
$site = New-Object Microsoft.SharePoint.SPSite($URL)
$web = $site.openweb("")
$list=$web.Lists["TestDocs"]
$listname = $list.title
Write-Host $list.title
$spQuery = New-Object Microsoft.SharePoint.SPQuery
#$camlQuery ="<Where><Or><Eq><FieldRef Name='ContentType' /><Value Type='Computed'>CV</Value></Eq><Eq><FieldRef Name='ContentType' /><Value Type='Computed'>Form FDA 1572</Value></Eq></Or></Where>"
$camlQuery = '<OrderBy><FieldRef Name="Title" Ascending="True" /></OrderBy>'
Write-Host $camlQuery
$spQuery.Query = $camlQuery
$spQuery.RowLimit = 100
Write-Host "Query string" $spQuery.Query
$spListItems = $list.GetItems($spQuery)
Write-Host "spListItems :" $spListItems
foreach ($item in $spListItems)
{
write-host "Name:" $item.Name
write-host "Title:" $item["Title"]
}
Comments
Post a Comment