Forum Discussion

Juan M Baena's avatar
Juan M Baena
Iron Contributor
Nov 16, 2018

File Type Aggregation

Good Day

 

This is a general question hoping in getting ideas/guidance.  Part of our business or user based asked if there is a way to somehow aggregate the document file type that is stored in OneDrives.  In other words our clients are looking to find out how many excel files, pdf files, onenote files, etc are being hosted on OneDrives.  The are some good out of the box reports in the tenant admin center for OneDrive showing metrics like number of files, active files, storage used etc.

 

To get the aggregated count of file types, is this something that could potentially be captured through an API or would we need for example in creating columns that can capture file type details so that we can then get a count doing this programmatically. Thank you!

  • There isn't a specific API call that does this Our of the Box.  There are a couple of potential approaches depending on if you need hard numbers or just estimates.

     

    If a rough estimate is OK, then I would suggest setting up a search scope that only searches OneDrive locations and then you can use file type as a filter and get a rough count.  It won't be perfect, but it should give you an order of magnitude for the tenant.

     

    Another approach would be to write some PowerShell to walk the Documents DocLib in each users OneDrive and then count the totals by file extension.  This will be slow, but accurate.  I wrote up a set of PowerShell that will pull the usage of all user's OneDrive for Business.  What you would need to do is change the Function GetODUsage to walk the files in the Documents and Total by File Type.  Here is the link to the article where I talk about how to pull all of the OneDrive usage  http://blogs.catapultsystems.com/dbroussard/archive/2015/10/20/pull-onedrive-for-business-usage-using-powershell/

     

    I found an article where a person has the code to pull all files in a DocLib and write out their names.  You should be able to make just a small change to pull counts instead.  Here is that link: https://www.morgantechspace.com/2017/06/get-all-list-items-in-library-using-powershell.html

     

    If you use my code to get the URLs for everyone, then use this block to open it using CSOM then you should be able to get everything that you need.

  • Paul de Jong's avatar
    Paul de Jong
    Iron Contributor

    Hi Juan,

     

    Are you looking for a solution to analyse multiple OneDrive for Business libraries or do you want individual users to be able to generate such a report for their own environment only?

     

    Paul | SLIM Applications

    • Juan M Baena's avatar
      Juan M Baena
      Iron Contributor

      Thank you all for the feeback, I really appreciate it. The goal would be in targeting several OneDrives (a slice covering one division not for the whole company).

      • Paul de Jong's avatar
        Paul de Jong
        Iron Contributor

        I would recommend to use PowerShell as the best solution.
        paul

Resources