获取文档库/列表中的项目集合 [英] Get a collection of items in document library/list
问题描述
我是 Powershell 的新手.我想要做的是获取文档库中所有文档的列表.例如,我有要处理的文档库的绝对 URL.
I'm new to Powershell. What I'm trying to do is get a list of all the documents in a document library. I have an absolute URL of the document library I want to process, for example.
基本上我想要的是对文档库的引用,以便我可以向它发送一些 CAML 查询.
Essentially what I want is a reference to the document library so I can send some CAML queries to it.
http://sharepoint2013/sites/superdupersite/shared%20documents
Add-PSSnapin Microsoft.SharePoint.Powershell
$items = Get-SPList "http://sharepoint2013/sites/superdupersite/shared%20documents"
foreach ($item in $item) {
#process
}
但是好像不行.如何在 powershell 中执行此操作?
But it doesn't seem to work. How can I do this in powershell?
推荐答案
在您的代码中将返回$items",如果它以预期的方式工作,它将包含一个 SPList 对象.试试这个:
In your code will return "$items" will contain an SPList object if it works in the expected manner. Try this:
Add-PSSnapin Microsoft.SharePoint.Powershell
$site = Get-SPSite "http://sharepoint2013/sites/superdupersite/"
$web = $site.OpenWeb()
$list = $web.Lists[Shared Documents] <Title of the list goes here>
$items = $list.GetItems()
foreach ($item in $items) {
#process
}
愉快的脚本编写 =)
这篇关于获取文档库/列表中的项目集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!