Do any one has any PS script to download sharepoint online usage report?

Sunny Rastogi 106 Reputation points

I had followed the some article to generate the report using Graph API, but I feel its generating storage report not the usage report and when I am comparing the Graph API generated usage report with actual usage report which I am downloading by clicking the download button in SharePoint site, its completely different as it has more tabs like Popular content, Usage by device, Usage by time etc....and its also showing the day to day activity, but in Graph API report these options are not coming.

Please suggest.

Do you have any custom PS script to generate the SharePoint Online site usage report? I am working on automation.

Note: I want to generate exactly the same Usage report using PS script as I am downloading it using download option in SharePoint Online site (It has tabs).50856-ss.png

Microsoft Office Online Server
Microsoft Office Online Server
Microsoft on-premises server product that runs Office Online. Previously known as Office Web Apps Server.
616 questions
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,273 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,460 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Kevin Morgan 6 Reputation points

    Hi @Tilo ,

    If interested, you can use Microsoft Graph PowerShell SDK to work with graph.

    Get started with the Microsoft Graph PowerShell SDK

    Once you installed the Graph SDK module. Run the following commands to connect the Graph with required permissions.

    #Connect Microsoft Graph  
    $RequiredScopes = @("Reports.Read.All")  
    Connect-MgGraph -Scopes $RequiredScopes  

    Use the following command to get SharePoint site usage details.

    Invoke-MgGraphRequest -Uri "'D180')" -OutputFilePath "C:\Temp\Report.csv"  

    As @MichaelHan-MSFT mentioned, refer the following documentation to get the desired graph end-point and use it in the above command.

    1 person found this answer helpful.
    0 comments No comments

  2. MichaelHan-MSFT 18,021 Reputation points

    Hi, @Sunny Rastogi ,

    As far as I know, there is no such PS script to generate the site usage report the same as the reoprt downloaded from the UI.

    Currently, if we want to generate sharepoint reports programmatically, we have to use the Graph API to acheive this. In offical graph documentation, there is only two kinds of sharepoint reports available:

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.