1

I have the following code and it seems it works fine, but it only returns things from the root site. We have like 200 subsites, and the script should return all pages where the contacts field on the page is not null

Get-SPWeb "https://xxxxx.com" |
   Select -ExpandProperty Lists |
   Where { $_.GetType().Name -eq "SPDocumentLibrary" -and
           -not $_.Hidden } |
   Select -ExpandProperty Items |
   Where { $_["Contacts"] -ne $null } |
   Select Name, {$_.File.Author}, url, {$_["Contacts"] }
1
  • What SharePoint version are you trying to query this information from?
    – TempaC
    Nov 7 '13 at 13:42
2

When passed a URL, Get-SPWeb only returns the SPWeb object for the specific site you list. To get all the sites and subsites in a site collection, pipe the SPSite object to Get-SPWeb like so:

Get-SPSite "http://whatever...." | Get-SPWeb -Limit All

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.