forked from jameswh3/MW-Toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-SharePointAgentInteractionAuditLogItems.ps1
More file actions
34 lines (29 loc) · 1.27 KB
/
Get-SharePointAgentInteractionAuditLogItems.ps1
File metadata and controls
34 lines (29 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
if ([string]::IsNullOrEmpty($startDate)) {
$startDate = (get-date).AddDays(-7).tostring("yyyy-MM-dd")
}
if ([string]::IsNullOrEmpty($endDate)) {
$endDate = (get-date).tostring("yyyy-MM-dd")
}
if ([string]::IsNullOrEmpty($upn)) {
$upn = Read-Host "Enter your UPN"
}
#Exchange Online Management Session; $set upn variable prior to running
Connect-ExchangeOnline -UserPrincipalName $upn
#region - Get All Record Types for the Date Range
$sessionId = "FileAccessed Operation SharePoint RecordTypes from $startDate to $endDate"
$allResults=@()
do {
$currentResult=Search-UnifiedAuditLog `
-StartDate $startDate `
-EndDate $endDate `
-SessionCommand ReturnLargeSet `
-SessionId $sessionId `
-RecordType "SharePointFileOperation" `
-Operations "FileAccessed","FileAccessedExtended"
$allResults += $currentResult
write-host "Current Result Count: $($currentResult.Count)"
write-host "All Result Count: $($allResults.Count)"
} while ($currentResult.Count -ne 0)
write-host "All items count: $($allResults.Count)"
$copilotAgentInteractionAuditLogItems = $allResults | Where-Object {$_.AuditData -like "*.agent*"}
write-host "SharePoint Agent items count: $($copilotAgentInteractionAuditLogItems.Count)"