Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am using Powershell to iterate through items in a document library and when I am running the ISE debugger there are no items in my list. I can see that the list is recognized, but I do not see any items.

Here's what I am attempting:

$site = New-Object Microsoft.SharePoint.SPSite("https://site")
$web = $site.OpenWeb()
$docLib = $web.GetList("https://site/docs") 

# $docLib.Items is blank
$items = $docLib.Items

Any ideas? Thank you!

share|improve this question
add comment

3 Answers

When I use SPWeb.GetList() I use a relative path like:

$docLib = $web.GetList("/Web/Lists/ListName")

If the actual path to the library is https://site/docs then try:

$docLib = $web.GetList("/docs")
share|improve this answer
add comment

Try this:

$docLib = Get-SPList -URL "https://site" -Title "DocLib Title"
$items = $docLib.Items
foreach ($item in $items)
{
 write-host $item.Name
}
share|improve this answer
add comment

try:

$list.Items | foreach-object { $_.Name }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.