Entra / Microsoft 365 · Compliance & audit
Report stream audit events
Report the audit events collected in the audit event log for Stream video creation and editing.
Connect & set up
Run these once per session. All scopes are read-only unless the script makes changes.
Connect-ExchangeOnline -SkipLoadingCmdletHelp
Run it
The main script. Copy it, or download the .ps1 and run it from your console.
param([int] $LookbackDays = 30,[string] $StartDate = (Get-Date).AddDays(-$LookbackDays),[string] $EndDate = (Get-Date).AddDays(1); $StartDate = (Get-Date).AddDays(-$LookbackDays))$Status = Get-ConnectionInformation -ErrorAction SilentlyContinueIf (!($Status)) {Connect-ExchangeOnline -SkipLoadingCmdletHelp}[array]$Operations = "FileUploaded", "FileModified", "FileAccessed"Write-Host "Looking for Stream audit events..."[array]$Records = (Search-UnifiedAuditLog -Operations $Operations -StartDate $StartDate -EndDate $EndDate `-Formatted -ResultSize 5000 -SessionCommand ReturnLargeSet)If (!($Records)) {Write-Host "No audit records found - exiting!"; break}Write-Host "Processing events..."$StreamEvents = [System.Collections.Generic.List[Object]]::new()$Records = $Records | Sort-Object CreatedDateTimeForEach ($Rec in $Records) {$AuditData = $Rec.AuditData | ConvertFrom-JsonIf (($AuditData.SourceFileExtension -in "mp4", "webm")) {$RecordingFileName = $AuditData.SourceFileName$DateLoc = $RecordingFileName.IndexOf("-202")$Topic = $nullIf ($DateLoc -eq -1) {$Topic = $RecordingFileName} Else{$Topic = $RecordingFileName.SubString(0,$DateLoc)}$DataLine = [PSCustomObject] @{Workload = $AuditData.WorkloadTimestamp = $Rec.CreationDateUser = $Rec.UserIdsRecording = $RecordingFileNameTopic = $TopicSite = $AuditData.SiteURLFullURL = $AuditData.ObjectIdFolder = $AuditData.SourceRelativeURLOperation = $Rec.Operations }$StreamEvents.Add($DataLine)} #End If} #End ForWrite-Host ""$StreamFileOperations = $StreamEvents | Sort-Object {$_.Timestamp -as [datetime]} | Where-Object { $_.User -ne "app@sharepoint" }$StreamFileOperations | Group-Object User | Sort-Object Count -Descending | Format-Table Name, Count$StreamFileOperations | Out-GridView
Parameters
ParameterDefaultNotes
-LookbackDays30Number of days back to search the unified audit log.-StartDate(Get-Date).AddDays(-10)Start of the reporting window.-EndDate(Get-Date).AddDays(1); $StartDate = (Get-Date).AddDays(-30)End of the reporting window.Attribution
Author
Office365itpros