2

I have written a below PowerShell script to get items of a library for SharePoint 2013

$spData = $web.Lists["EmployeeDocument"] -as [Microsoft.SharePoint.SPDocumentLibrary]
$fieldsItems = $spData.Items

$result = $fieldsItems | select Title,FolderCategory

$filterItem =  $fieldsItems | ? {$_.FolderCategory -eq "Help"}

This script does not return the result and filter of the Library.

Where as, below script return 3 items count:

$spData.Items.Count

Thanks in advance

5
  • You need Item count library? Commented Aug 27, 2017 at 17:35
  • @Mikhail: I have a mentioned $spData.Items.Count to specify that library "EmployeeDocument" consist of three items... Commented Aug 27, 2017 at 17:42
  • First try to don't cast as libary, try to jandle it like a normal list. I had aame sideeffects with this too two weeks ago. Only the plain list gave me the items back. Commented Aug 27, 2017 at 18:48
  • Sorry, its don't work even after using the normal list. Commented Aug 28, 2017 at 2:02
  • I suggest you print the results before assigning, so you can see what you are doing wrong. e.g. $fieldsItems | select Title, FolderCategory. Odds are your FolderCategory property is empty Commented Aug 28, 2017 at 11:41

1 Answer 1

0

try to fetch the list as below:

web.lists.GetByTitle("TestList")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.