Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果修改或删除CAML查询,SPList将不返回结果_List_Powershell_Sharepoint_Caml - Fatal编程技术网

如果修改或删除CAML查询,SPList将不返回结果

如果修改或删除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

我有一个SharePoint PowerShell脚本,它从列表中获取项目

我正在为不同的输出更改CAML查询

但是,在更改或删除CAML查询时,list.GetItems方法返回0结果,我不知道为什么会这样

下面是我的代码片段:

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是否适合此列表。您可以提供有关列表自定义列表或文档库以及此列表的所有内容类型的更多信息,以供进一步研究