Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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"].

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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

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

share|improve this answer

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)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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