What PowerShell code can query SharePoint Online Audit data and return a total number of visitors and unique visitors in the last 90 days?

frob 4,261 Reputation points
2023-06-08T16:22:36.44+00:00

Hi there

What PowerShell code can query SharePoint Online Audit data and return a total number of visitors and unique visitors in the last 90 days?

Thanks.

Microsoft 365 and Office Install, redeem, activate For business Windows
Microsoft 365 and Office SharePoint For business Windows
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-06-09T06:42:07.69+00:00

    Hi @frob ,

    Do you want to use PowerShell to query SharePoint Online audit data and retrieve total and unique visitors for the past 90 days?

    Here's an example code snippet that demonstrates this:

    Please adjust the date in the code:$startDate = (Get-Date).AddDays(-90)

    $endDate = Get-Date

    Please note that although the cmdlet is part of the Exchange Online Management Shell, it can be used to retrieve audit logs for SharePoint Online as well

    User's image

    Here is link for your reference:

    SharePoint Online: How to View Audit Log Reports in Security & Compliance Center? - SharePoint Diary


    ​​

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.

    Best Regards

    Cheng Feng


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.