SOLVED

How to Get Email Activity User report of Office 365 using PowerShell Script?

Occasional Visitor

Hi, 

I am looking for Email Activity user Details report using power shell script., Which will run through scheduler in weekly basis and create a csv file in my desired location. The report format and data field would be same as the report which I can get through  Office 365 Admin portal(Microsoft 365 admin center - Email activity). How can I get the same report using PowerShell script.  I do have user role of "Global Reader"and "Report Reader". Is it sufficient to run PS script to get all the user's email activity report?

For more clarification below is the sample report format: Among those  I am looking for the highlighted column Names:

 

Report Refresh Date,User Principal Name,Display Name,Is Deleted,Deleted Date,Last Activity Date,Send Count,Receive Count,Read Count,Meeting Created Count,Meeting Interacted Count,Assigned Products,Report Period

 

I tried with this scrip: MailtrafficReport.ps1 

But the row count is not same as the report I am getting manually from Admin portal. Its giving me only few rows and less columns as output. For example : From Admin portal I am getting the report of 7 days with  56k rows whereas with this upper mentioned powershell script I am getting only 6k numbers of row and less columns as output.

 

Please help me to resolve this.

1 Reply
best response confirmed by sajjad765 (Occasional Visitor)