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?
    – user37251
    Aug 27, 2017 at 17:35
  • @Mikhail: I have a mentioned $spData.Items.Count to specify that library "EmployeeDocument" consist of three items... 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.
    – Sascha
    Aug 27, 2017 at 18:48
  • Sorry, its don't work even after using the normal list. 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 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 that you have read and understand our privacy policy and code of conduct.

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