Calling Recursive function with Powershell to list all documents in the document library under a SIte collection

 function Recurse($RootFolder,$List) {
                        $Context.Load($RootFolder)
                        $Context.Load($RootFolder.Folders)
                        $Context.ExecuteQuery()
                        foreach($folder in $RootFolder.Folders)
                            if($Folder.Name -ne "Forms")
                                    $Context.Load($folder)
                                    $Context.Load($folder.Files)
                                    $Context.ExecuteQuery()
                                    foreach($file in $folder.Files)
                                        $FileCollection +=
$file
                                    Recurse $folder $List 
                            Recurse $folder.ParentFolder $List
                            Return $FileCollection
I am trying to traverse through SharePoint Online Site collection using Powershell CSOM. I am able to go to the last folder from the root folder which is 2-3 levels down. But I could not search through all the document libraries as it gets struck to one
of the last document library.

Below script is working for me. I can now traverse through all the folders and subfolders including the root folders to fetch all the files using Powershell and CSOM.
#function begins
                    function Recurse($RootFolder) {
                        $Context.Load($RootFolder)
                        $Context.Load($RootFolder.Folders)
                        $Context.ExecuteQuery()
                        $Context.Load($RootFolder.Files)
                        $Context.ExecuteQuery()
                        $resultCollection = @()
                        foreach($file in $RootFolder.Files)
                            $resultCollection += $file
                        foreach($folder in $RootFolder.Folders)
                            if($Folder.Name -ne "Forms")
                               Recurse $folder  
                            Return $resultCollection
                    # Function ends

Similar Messages

  • Powershell to list all computers and the complete OU path

    I am trying to get a list of All Computers within the domain Prefixed UK and have it export the list to a CSV with the full OU Path.
    So far I can get the computers but not the OU
    Get-ADComputer -Filter 'SamAccountName -like "UK*"' | Select -Exp Name 
    Thanks

    Hi,
    What do you mean by 'complete OU path'? If you look at the DistinguishedName property of the returned computer object, you'll see the full path there.
    Don't retire TechNet! -
    (Don't give up yet - 12,700+ strong and growing)

  • GL Report listing all lines from the documents used

    Hi Experts
    The standard GL Report is printed from SAP only GL level transactions.
    I would like to produce a printed report by inputting a GL Code and a date range. Output should be all transactions that have been posted to that account during the specified time period.  The important requirement of this report is that  transactions should actually contain details from the source documents ie a figure from an AP invoice should go on to list the lines on that AP invoice that are relevant to this account. Same applies to AR Invoices, Inventory transactions, etc, etc. Any GL Account specified and details of all
    Is there a report in SAP that can achive this or is there a query that can be run to achieve above
    Thank you
    Regards
    Apsara

    Hi Apsara Senaratna,
    I believe that the General Ledger report in SAP can cater your need. (Go to Financials > Financials Reports > Accounting > General Ledger.)
    But you just have to uncheck BP, then mark (x) to what GL accounts you want to show details. Then you could also set parameters for Posting, Due, and Document Dates.
    Hope this helps!
    Thanks!

  • How to call a function with pl/sql

    How does one call a function with pl/sql that uses a function?

    Hi,
    How does one call a function with pl/sql that uses a
    function?I'm not sure what you mean.
    In PL/SQL function can be used just about anywhere where an expression (with the same data type that the function returns). Arpit gave a very common example.
    Here's another example, where all the functions take a single NUMBER argument and return a NUMBER, so they can all be used in places where NUMBERs are used:
    IF  fun_a (fun_b (0)) < fun_c (1)
    THEN
        UPDATE  table_x
        SET     column_y = fun_d (2)
        WHERE   column_z = fun_e (ROUND ((fun_f (3), fun_g (4)));You call a function simply by using its name, followed by its argument list, if any.
    If the function is in a package, you must call it with the package name, like "pk_foo.bar (1, 2, 3)", unless the call comes from within the same package.
    If the function is owned by someone else, you must give the owner name, like "scott.bar (SYSDATE)" or "scott.pk_foo.bar (1, 2, 3)". You can create synonyms to avoid having to name the owner.

  • Calling Recursive function in a transaction

    Hello All
    I have a requirement calling Recursive function in Transaction.Means inside a transaction, i want to call the same transaction.Is it possible to do like this?
    Because when i am calling like this,transaction is running contineously without stop.
    Any help would be highly appreciated.
    Thanks,
    Manisha

    Manisha,
    take a look on this thread:
    Does xMII support recursive Business Logic Modules
    Hope Ricks solution can help you.
    Regards
    Pedro
    Edited by: Pedro Iglesias on Dec 19, 2008 9:56 AM

  • Call outside function with same name in a package

    I created a function as follows:
    create or replace function f1 return number
    is
    begin
    return 1;
    end;
    This f1 is to be called in a package created below.
    Then I create a package with a function in it, as follows:
    create or replace package pack1 as
    function f1 return number;
    end;
    Now I define the package body as follows:
    create or replace package body pack1 as
    function f1 return number as
    -- I am trying to call the first function f1 defined above here
    How do I resolve the name issues here?
    In other words, I want to call a function with the same signature outside a package.
    Thanks for your kind help.

    Hi,
    Welcome to the forum!
    Do you have a good reason for using the same name?
    Refer to the stand-alone function with the owner name, even though it's your current schema.
    That is, even if the package and the stand-alone function are owned by scott, in the package, say
    x := scott.f1;

  • Is there a way to call a function with in the initializer of a ArrayCollection?

        Is there a way to call a function with in the initializer of a ArrayCollection?
    It won't let me do this:
    var ac:ArrayCollection = new ArrayCollection([
                        {childName:'addTrade',index:addTradeIndex },
                        {childName:'tradeList',dealsCanvas.getChildIndex(tradeList) }

    The correct syntax is
    var ac:ArrayCollection = new ArrayCollection([
                        {childName:'addTrade',index:addTradeIndex },
                        {childName:'tradeList',index:dealsCanvas.getChildIndex(tradeList) }

  • How to call a function with event

    How do I call a function with a event inside it?
    function showTopTen(e:Event):void
        highscoreData = new XML(e.target.data);
        trace("Hiscores: " + highscoreData.item[0].name.text() + " - " + highscoreData.item[0].score.text())
    //showTopTen();  ..??

    Could you indicate why you would want to?
    The eventhandler you show here uses the properties of the event object passed as an argument.
    The way I read it it is data retrieved from a server so your app won't know anything about is untill it is loaded from the server which should be done with an URLLoader object which in it's turn calls your eventHandler when the Event.COMPLETE is triggered.
    something like:
    var urlLoader = new URLLoader();
    urlLoader.addEventListener( Event.COMPLETE, showTopTen )
    urlLoader.load( new URLRequest( "http:// etc." ) );
    to me would seem the proper method to have the function execute.

  • How to call java function with parameter from javascript in adf mobile?

    how to call java function with parameter from javascript in adf mobile?

    The ADF Mobile Container Utilities API may be used from JavaScript or Java.
    Application Container APIs - 11g Release 2 (11.1.2.4.0)

  • HT4436 how do I set up an icloud account on my macbook pro with 10.6.8 - all it has is mobile me under internet and wireless????

    help, how do I set up an icloud account on my macbook pro with 10.6.8 — all it has is "mobile me" under internet and wireless on my system doc????

    You should check that your Mac meets the requirements for upgrading.
    The requirements for Lion are:
    Mac computer with an Intel Core 2 Duo, Core i3, Core i5, Core i7, or Xeon processor
    2GB of memory
    OS X v10.6.6 or later (v10.6.8 recommended)
    7GB of available space
    To purchase it you will have to ring Apple at the number given at the bottom left of this page.
    The requirements for Mountain Lion are listed here:
    http://www.apple.com/osx/specs/
    It is available from the Mac App Store (in Applications).
    You should be aware that PPC programs (such as AppleWorks) will not run on Lion or above; and some other applications may not be compatible - there is a useful compatibility checklist at http://roaringapps.com/apps:table

  • HT4915 How to I completely delete my music in iCoud so I can start over with new play lists? I get the message that my files aren't  music files. Can I see what is in my iCloud file?

    How to I completely delete my music in iCoud so I can start over with new play lists? I get the message that my files aren't music files. Can I see what is in my iCloud file?

    Thank you Csound1, ok I guess I did manage to delete it but now when I copy new mp3 files they come as mpeg and iCoud won't accept them? Why? Do I have to convert them all now or can I set it somewhere to take them as mp3's. Appreciate the help. Have a great day! Cheers Steve

  • Blank page with quick reply on all mybb forums, the same thing was with Fire fox 3.0.1?

    blank page with quick reply on all mybb forums, the same thing was with Fire fox 3.0.1?
    == URL of affected sites ==
    http://world.alnel.com

    I know we already had this feature, but it was through a modification, not an official feature. It is now an official feature and it is implemented quite well in my opinion. Also new - you can now modify the title/subject of threads that you posted right from the forum display - just click and hold on the link to the thread, and it'll change to a textbox. Then just click out of the box or hit enter to save!
    [url=http://www.micrositez.co.uk/link-building-packages.html] Link Building[/url]|[url=http://www.micrositez.co.uk/link-building-packages.html] Link Building Services[/url]

  • After making a photopresentation and saved it as a quicktime mov with music i lost all tittles in the presentation, what have i done wrong?

    after making a photopresentation and saved it as a quicktime mov with music i lost all tittles in the presentation, what have i done wrong?

    Please, help me I have now 10 copies of my Photoslide show with music but still without the tittles(text) I added to the pictures. I used the original file name to add my text. Who know,s how to solve this problem or o I have to start again.
    Thanks for any help.
    Paul

  • Have new iMac with iPhoto sharing turned on. When the shared library is clicked the library disappears or starts to load then disappears? What is wrong?

    Have new iMac with iPhoto sharing turned on. When the shared library is clicked the library disappears or starts to load then disappears? What is wrong?

    Try this:  launch iPhoto with the Option key held down and create a new, test library.  Import some photos and check to see if the same problem persists. If it doesn't then your current library is damaged and needs repair.
    Therefore  make a temporary, backup copy (select the library and type Command+D) and  apply the two fixes below in order as needed:
    Fix #1
    Launch iPhoto with the Command+Option keys held down and rebuild the library.
    Since only one option can be run at a time start with Option #1, followed by #3 and then #4 as needed.
    Fix #2
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    Download iPhoto Library Manager and launch.
    Click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option
    In the next  window name the new library and select the location you want it to be placed.
    Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments but not books, calendars or slideshows. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
    If you experience the same problem with the test library then try this basic fix a try:  make a temporary, backup copy (if you don't already have a backup copy) of the library and try the following:
    1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your
         User/Home()/Library/ Preferences folder.
    2 - delete iPhoto's cache file, Cache.db, that is located in your
         User/Home()/Library/Caches/com.apple.iPhoto folder. 
    Click to view full size
    3 - launch iPhoto and try again.
    NOTE: If you're moved your library from its default location in your Home/Pictures folder you will have to point iPhoto to its new location when you next open iPhoto by holding down the Option key when launching iPhoto.  You'll also have to reset the iPhoto's various preferences.
    NOTE 2:  In Lion and Mountain Lion the Library folder is now invisible. To make it permanently visible enter the following in the Terminal application window: chflags nohidden ~/Library and hit the Enter button - 10.7: Un-hide the User Library folder.
    If that fails a reinstall of iPhoto is indicated. To do so you'll have to delete the current application and all files with "iPhoto" in the file name with either a .PKG or .BOM extension that reside in the HD/Library/Receipts folder and from the /var/db/receipts/  folder,
    Click to view full size
    Then install iPhoto from the source it came on originally.
    OT

  • We are unable to open a Pages 5.0.1 document in Pages 4.2 and retain ability to edit all aspects of the document. I have tried saving the 5.0.1 version as Pages '09 and am still unable to open it in the earlier version of pages. Help?

    We are unable to open a Pages 5.0.1 document in Pages 4.2 and retain ability to edit all aspects of the document. I have tried saving the 5.0.1 version in Pages '09 but am still unable to open it in the earlier version of pages. Help?

    No, it isn't. Pages 5 isn't compatible with Pages 4.3 as it is lacking more than 90 features that Pages 4 has. So when you open a Pages 4 document in Pages 5 only the simplest documents will look the same in Pages 5.
    Pages 4 can't open Pages 5 documents at all!! You have to export back to Pages 09 as I said above.
    You probably will be more happy if you just use Pages 4 (Pages 09). There are many threads in this forum that describes the lack of compatibility between the two versions. Pages 5 is in my view not Pages anymore.
    If you don't desperately need Pages 5 for moving documents over iCloud to new iOs devices don't use it.

Maybe you are looking for

  • PHP and OCI-Lob::read from oracle clob

    I'm having a weird problem with PHP and the OCI-Lob::read method. We have a page that connects to the database and pulls all the other fields out with no problems. However, it when it comes to the clobs, only a small portion of the actual data is ret

  • Loading xml data into the datagrid

    Hi all, I'm trying to learn Flex. I have a small doubt in loading the datagrid from the xml response (from php script) mxml code: <mx:DataGrid id="dataGrid" x="69" y="250"> <mx:columns> <mx:DataGridColumn headerText="Name" dataField="name"/> <mx:Data

  • NotActiveException when Using ObjectInputStream

    package serialization; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.NotActiveException; import java.io.ObjectInputStream; import java.io.ObjectOutput

  • Can't view pictures after update to 08

    I recently updated to Ilife 08. After the holidays I downloaded pictures from my digital canon rebel camera as usual. I can see the new pictures as smaller thumbnails but if I increase the size of the thumbnail, they disappear and I get a gray dashed

  • Possible Bug in Facebook Upload Program

    I have been using Aperture for quite some time now and think that I have found an obscure bug.  I took some photos over the weekend and one of them was a picture of an owl.  The eyes were red, so I used the red-eye removal feature to correct this pro