I am trying to use Powershell to query my Sharepoint site so I can get a list of items to use as input in my migration script. I have a document library (Site Assets), which has a folder (Calendar Pages) in it with a bunch of .aspx pages. I'd like to migrate these pages to another site.

Using Powershell, I can get a reference to the Site Assets library with: $web.Lists["Site Assets"]. I can't seem to get a reference to any objects further than this, however. I've tried $web.Lists["Site Assets"].Lists["Calendar Pages"] and $web.Lists["Site Assets"].Folders["Calendar Pages"].


No overload of the SPList.Folders collection takes a string.

Try $web.Lists["Site Assets"].RootFolder.SubFolders["Calendar Pages"].


Try this:

$web.Lists["Site Assets"].Folders | where { $_.Name -eq "Calendar Pages" }

$web.Lists["Site Assets"].Lists["Calendar Pages"] does not work because "Calendar Pages" is not a List, it's a folder.

$web.Lists["Site Assets"].Folders["Calendar Pages"] does not work because $web.Lists["Site Assets"].Folders is of type SPListItemCollection which does not allow you to index by name (only by index and guid)

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.