如果修改或删除CAML查询,SPList将不返回结果
我有一个SharePoint PowerShell脚本,它从列表中获取项目 我正在为不同的输出更改CAML查询 但是,在更改或删除CAML查询时,list.GetItems方法返回0结果,我不知道为什么会这样 下面是我的代码片段:如果修改或删除CAML查询,SPList将不返回结果,list,powershell,sharepoint,caml,List,Powershell,Sharepoint,Caml,我有一个SharePoint PowerShell脚本,它从列表中获取项目 我正在为不同的输出更改CAML查询 但是,在更改或删除CAML查询时,list.GetItems方法返回0结果,我不知道为什么会这样 下面是我的代码片段: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Set config variables $baseUrl="http://test.com/" $listNam
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Set config variables
$baseUrl="http://test.com/"
$listName ="Lists/FilePlan"
#Get Web and List Objects
$web = Get-SPWeb $baseUrl
$list = $web.GetList($listName)
#Define the CAML Query
$queryOriginal = New-Object Microsoft.SharePoint.SPQuery
$queryOriginal.Query = "@
<Where>
<Eq>
<FieldRef Name='ContentType' />
<Value Type='Text'>Folder Content Type</Value>
</Eq>
</Where>"
$queryModified = New-Object Microsoft.SharePoint.SPQuery
$queryModified.Query = "@
<Where>
<Eq>
<FieldRef Name='ContentType' />
<Value Type='Text'>Document Content Type</Value>
</Eq>
</Where>"
#Get List Items matching the query
$items = $list.GetItems($queryOriginal) //result
$items2 = $list.GetItems($queryModified) //zero result*****
$items3 = $list.GetItems() //zero result*****
编辑:
已尝试使用,但也无效。您可以查看下面的PowerShell脚本
#Set config variables
$baseUrl="http://test.com/"
$listName ="FilePlan"
#Get Web and List Objects
$web = Get-SPWeb $baseUrl
$list = $web.Lists[$listName]
$items = $list.Items
$items.Count
然后可以检查ContentType是否适合此列表。您可以提供有关列表自定义列表或文档库以及此列表的所有内容类型的更多信息,以供进一步研究