Report SharePoint Online Site Usage Data with PowerShell

Report SharePoint Online Site Usage Data with PowerShell

Introduction 

Businesses increasingly rely on digital platforms, which makes monitoring and analyzing website usage data even more crucial. In SharePoint Online, understanding how users interact with a site can help you optimize content, improve navigation, and identify security risks. In this article, we'll explore how to report SharePoint Online site usage data with PowerShell.

 

 Why reporting SharePoint Online site usage data is important? 

The SharePoint Online site usage reporting tool provides site administrators with valuable information about the site's usage. The purpose of usage reports is to identify patterns in user behavior, measure the effectiveness of site content, and identify potential security problems. By using these, a site administrator can optimize the performance of a site, improve the user experience, and comply with industry regulations by analyzing usage data.  

 

 Section 1: Setting PowerShell up for Reporting 

The SharePoint Online environment must be configured before PowerShell can report site usage data. This includes connecting to SharePoint Online with PowerShell and understanding the SharePoint Online Management Shell.

 

 Connecting to SharePoint Online with PowerShell 

To connect to SharePoint Online with PowerShell, you need to have the SharePoint Online Management Shell installed on your machine. It can be downloaded from the Microsoft website. After installing,

 

  1. Open the SharePoint Online Management Shell.

  2. Run the following command:

Connect-SPOService -Url https://yourdomain-admin.sharepoint.com

Replace "yourdomain" with your SharePoint Online domain name.

  1. Next, enter your SharePoint Online administrator credentials when prompted. It will establish a connection between your local machine and your SharePoint Online environment.

 

 SharePoint Online Management Shell 

The SharePoint Online Management Shell is a command-line interface for managing SharePoint Online. It provides a set of PowerShell cmdlets that can be used to perform various tasks, including reporting site usage data.

 

Some of the cmdlets that you may find useful for reporting site usage data include:

 

  • Get-SPOSite: retrieves information about SharePoint Online sites

  • Get-SPOUser: retrieves information about SharePoint Online users

  • Get-SPOUserLicense: retrieves information about SharePoint Online user licenses

 

 Section 2: Collecting SharePoint Online Site Usage Data 

SharePoint Online site usage data provides valuable insights into how users are interacting with your site. By collecting and analyzing usage data, you can make informed decisions about how to improve site performance and user experience. In this section, we'll cover how to collect SharePoint Online site usage data using PowerShell.

 

 Overview of SharePoint Online Site Usage Data 

SharePoint Online site usage data includes information about page views, unique visitors, and other site interactions. This data can be accessed through the SharePoint Online Management Shell, which provides a set of cmdlets for collecting and analyzing usage data.

 

 Collecting Usage Data with PowerShell Cmdlets 

To collect usage data using PowerShell, you'll need to connect to SharePoint Online and run the appropriate cmdlets. Here's how:

 

  1. Connect to SharePoint Online with PowerShell using the Connect-SPOService cmdlet.

  1. Run the Get-SPOSite cmdlet to retrieve information about the site you want to collect data for.

  1. Run the Get-SPOUserUsage cmdlet to retrieve user usage data for the site.

    • Enter the following command:
      Get-SPOUserUsage -Site https://yourdomain.sharepoint.com/sites/yoursite

    • This will retrieve user usage data for the entire site. If you want to retrieve usage data for a specific user, add the -UserName parameter followed by the user's email address.

  1. Run the Get-SPOWebPartUsage cmdlet to retrieve web part usage data for the site.

    • Enter the following command:
      Get-SPOWebPartUsage -Site https://yourdomain.sharepoint.com/sites/yoursite

    • This will retrieve web part usage data for the entire site. If you want to retrieve usage data for a specific web part, add the -Identity parameter followed by the web part's name.

 

 Creating Custom Usage Reports with PowerShell 

PowerShell provides the flexibility to create custom reports based on your specific needs. Here's how to create a custom usage report:

 

  1. Run the Get-SPOUserUsage cmdlet to retrieve user usage data for the site.

  • Use the Start-Date and End-Date parameters to specify the date range for the data you want to collect.

  • Use the Identity parameter to specify the URL of the site you want to collect data for.

  • Use the Limit parameter to limit the number of results returned.

  1. Export the data to a CSV file using the Export-CSV cmdlet.

  • Use the Path parameter to specify the file path and name for the CSV file.

  • Use the NoTypeInformation parameter to exclude the type information from the CSV file.

  1. Open the CSV file in Excel and create a chart or pivot table to analyze the data.

  • Open Microsoft Excel and select "Open" from the "File" menu.

  • Browse to the CSV file you created and select "Open".

  • Excel will open the file and display the data in a table.

  • Select the data you want to analyze and click on "Insert" from the menu.

  • Choose either "PivotTable" or "Chart" depending on how you want to display the data.

  • Follow the prompts to customize the table or chart to your desired format.

 

 

 Automating Usage Data Collection with PowerShell Scripts 

Collecting usage data manually can be time-consuming, especially for large sites. PowerShell scripts can be used to automate the collection of usage data, making it more efficient and less prone to error. Here's how to automate usage data collection with PowerShell:

 

  1. Create a PowerShell script that connects to SharePoint Online and retrieves usage data for the desired site:

  • Open PowerShell ISE (Integrated Scripting Environment).

  • Begin the script by using the Connect-SPOService cmdlet to connect to SharePoint Online.

  • Use the Get-SPOSite cmdlet to retrieve information about the site you want to collect data for.

  • Use the Get-SPOUserUsage cmdlet to retrieve user usage data for the site.

  • Use the Get-SPOWebPartUsage cmdlet to retrieve web part usage data for the site.

  • Use the Export-CSV cmdlet to save the usage data to a CSV file.

  1. Schedule the script to run at regular intervals using the Task Scheduler or other automation tool:

  • Open the Task Scheduler.

  • Click on "Create Task" to create a new task.

  • In the General tab, give the task a name and description.

  • In the Triggers tab, select how often you want the script to run (e.g., daily, weekly, monthly).

  • In the Actions tab, add the path to the PowerShell script and any necessary arguments.

  • In the Settings tab, configure any additional settings, such as whether to run the task when the user is not logged on.

  • Click "OK" to save the task.

Once the task is set up, the script will run automatically at the specified intervals, collecting usage data for the site without requiring manual intervention.

 

By following these steps, you can easily collect and analyze SharePoint Online site usage data using PowerShell. This can help you make data-driven decisions to improve site performance and user experience.

 

 Additional Resources   

To further enhance your knowledge on reporting SharePoint Online site usage data, here are some additional resources and recommended reading:

 

 

 Recommended Reading   

 


    • Related Articles

    • How to remove single, multiple and disconnected mailboxes in SharePoint online

      Introduction Are you struggling to manage your Exchange Server mailboxes? Removing unused or unnecessary mailboxes can help optimize your Exchange Server environment, making it more efficient and easier to manage. Managing Exchange Server mailboxes ...
    • How to automate and troubleshoot mailbox removals – Microsoft exchange online

      Managing mailboxes in an Exchange Online environment can be a daunting task for IT administrators, especially when it comes to removing multiple mailboxes. Manually removing mailboxes one by one is time-consuming and prone to errors. However, with ...
    • How to configure GPO in Active Directory at Site, Domain and OU levels

      Introduction Active Directory network multiplies over time and it may become incommodious to manage. There is a myriad of things that need to be controlled such as security permissions, software installation, desktop settings for users and computers, ...
    • 18. PowerShell - Drives and providers

      In the context of PowerShell, drives are logical data containers that provide access to various data sources, such as file systems, registry hives, and even Active Directory. These drives act as a consistent interface for administrators to interact ...
    • 16. PowerShell - "Passthru" Parameter

      Introduction: PowerShell, Microsoft's versatile command-line shell and scripting language, empowers administrators and developers to automate and manage Windows systems efficiently. Parameters play a crucial role in PowerShell, facilitating data flow ...