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:


Thanks in advance

  • You need Item count library? – user37251 Aug 27 '17 at 17:35
  • @Mikhail: I have a mentioned $spData.Items.Count to specify that library "EmployeeDocument" consist of three items... – RajeshSharepointGeek Aug 27 '17 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 '17 at 18:48
  • Sorry, its don't work even after using the normal list. – RajeshSharepointGeek Aug 28 '17 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 – Tiago Duarte Aug 28 '17 at 11:41

try to fetch the list as below:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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