Forum Discussion

Robert Bollinger's avatar
Robert Bollinger
Brass Contributor
May 05, 2020

Search-UnifiedAuditLog - List of users.

Hey Guys, 

Trying to generate a report of users who logged into office 365 and/or their mailbox. Just need to be able to use an input file. 

 

I found this script here: 

 

To Generate the Data

 

$ConvertAudit = Search-UnifiedAuditLog  -StartDate "04-01-2020" -EndDate "04-10-2020" -UserIds "robert@domain.com" -ResultSize 5000

 

To produce the report:

 

$ConvertAudit | Select-Object -ExpandProperty AuditData | ConvertFrom-Json | Select-Object CreationTime,UserId,Operation,Workload,ObjectID,SiteUrl,SourceFileName,ClientIP,UserAgent

 

The script is great! It allows you to export data for a single user, and format that data from JSON to Excel. This is what i needed!! 

 

The only problem i am having is i want to be able to use the above script and run it against an input file. The input file would have a list of users email addresses. (PrimarySMTP). 

 

I have tried to "fix it myself" and have not gotten anywhere. Any help would be appreciated. 

 

Thanks, 

 

Robert 

Resources