$ list.item PowerShell命令适用于一个站点,但不适用于另一个站点 [英] $list.item PowerShell command works on one site, but not another

查看:83
本文介绍了$ list.item PowerShell命令适用于一个站点,但不适用于另一个站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在2个不同的网站集中有2个不同的网站。 它们位于同一个服务器场中的同一Web应用程序中。 我试图使用PowerShell列出列表中的所有项目,它适用于其中一个站点,但不适用于其他站点。 
以下是两个脚本:

I have 2 different sites, in 2 different site collections.  They are in the same web application on the same farm.  I am trying to list all of the items in a list using PowerShell, and it works for one of the sites, but not for the other.  Here are the two scripts:

$ web = Get-SPWeb" https://site.company.com/siteA/siteB"

$ list = $ web.Lists [" ListA"]

$ list.Items



$ web = Get-SPWeb" https://site.company.com/sitecollC/siteD"
$
$ list = $ web.Lists [" ListB"]

$ list.Items

$web = Get-SPWeb "https://site.company.com/siteA/siteB"
$list = $web.Lists["ListA"]
$list.Items

$web = Get-SPWeb "https://site.company.com/sitecollC/siteD"
$list = $web.Lists["ListB"]
$list.Items

在第一个脚本中,  https://site.company.com是网站集。 在第二个脚本中,https://site.company.com/sitecollC是网站集。

In the first script, https://site.company.com is the site collection.  In the second script, https://site.company.com/sitecollC is the site collection.

第一个脚本将返回ListA中的所有项目,但是在第二个脚本中脚本,$ list.Items命令不返回任何内容,即使列表中有数千个项目。  Get-SPWeb有效,$ web.lists将返回网站中的所有列表。 
我只是不确定为什么它没有看到ListB中的项目

The first script will return all of the items in ListA, but in the second script, the $list.Items command returns nothing, even though there are thousands of items in the list.  Get-SPWeb works, and $web.lists will return all of the lists in the site.  I am just not sure why it isnt seeing the items in ListB

推荐答案

您可以使用PowerGUI调试脚本,这样可以帮助您了解问题(检查是否

You could use PowerGUI to debug your script so it would help you know the issue(check whether


列表正确返回。
list is returned properly).

如果您的列表项超过列表限制,添加查询以限制查询项目。

以下是一些供您参考的链接。

https://gallery.technet.microsoft.com/office/How-to-do-a-CAML-Query-6f5260cf

https://blogs.msdn.microsoft.com/kaevans/2012/02/13/i terating-large-sharepoint-lists-with-powershell /

最诚挚的问候,

Lee


这篇关于$ list.item PowerShell命令适用于一个站点,但不适用于另一个站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆