nayakasu
nayakasu

Reputation: 969

Iterate through SharePoint library folders,subfolders and items

I have a SharePoint library with document sets on level 1. Then inside document sets I have Folders and some documents(word,excel,txt) on level 2. Then again inside folders in level 2 I have some documents and folders and so on. I have to write a powershell script to go through all the folders,subfolders and find documents and update some columns. I have tried and I am able to iterate through all subfolders but I don't know how to get the items(documents) in every level. please help!

Level 1- Document sets
Level 2- Folders and documents
Level 3- Folders and documents
...

My requirement is to iterate through all levels update a column of document and then go into folders in that level.

Upvotes: 0

Views: 1577

Answers (1)

nayakasu
nayakasu

Reputation: 969

As it turns out it's very simple to achieve. Below is the code :

$itemsCollection = $list.Items | ? {$_["HTML File Type"] -ne "SharePoint.DocumentSet"}

It stores all the items in $itemsCollection variable. I realized that $list.Items only returns the documents and document sets and folders. So I used this to get only all the doucments in the library.

Upvotes: 0

Related Questions