0

I have found 100's of pages about getting groups, but best I can find about getting a list of all document is killing me!!

I have altered my script which works well with groups and tried to change it to documents.. but literally nothing is working for me.. executes and no errors

     $site = Get-SPOSite https://mysharepointsite.sharepoint.com/sites/construction
#Get all web sites in the site collections
$wc = $site.AllWebs
   foreach($w in $wc)
   {
      write-host "in-loop-one" -foreground "magenta"
      #loopthrouh the lists and libraries in the site
      foreach($l in $w.Lists)
      {
                write-host "in-loop-two" -foreground "magenta"
        #Check for only document libraries
        if($l.BaseTemplate -eq "DocumentLibrary")
        {
                        write-host "in-if-three" -foreground "magenta"
            Write-Host $l.Title"(Web: "$w.Title")"
        }
      }1
    }

--

None of the write-host are triggering..

I have a document library called "documents" with 360 items in it.. I am trying to get a list of each of thoses documents..

can anyone point me in the right direction?

1
  • Did you copy that verbatim? There's an errant 1 on the second-to-last line there. Otherwise, are you sure that the call to Get-SPOSite is returning a site collection? If not, $site will be $null, and there will not be any $w in $wc. If $site -ne $null, there will be at least one SPWeb (namely $site.RootWeb), so the first Write-Host will display. – Jeff Freeman Sep 11 '17 at 16:49
0

The get-sposite cmdlet is available for SharePoint online, but check the docs for the object it returns, as it lacks anything for working with webs, lists, libraries, etc. Instead, we need to turn to either the CSOM or the PNP cmdlets (which use the CSOM).

A post that shows how to loop through webs via the CSOM is here.

Here's the docs for PNP for the command that returns all items from a given list. Again, see the docs, as other cmdlets are available for getting webs or lists.

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.