@@ -34,10 +34,11 @@ function Test-CIPPAuditLogRules {
34
34
LogType = $_.Type
35
35
}
36
36
}
37
- Write-Warning ' Getting audit records from Graph API'
37
+ # write-warning 'Getting audit records from Graph API'
38
38
$SearchResults = Get-CippAuditLogSearchResults - TenantFilter $TenantFilter - QueryId $SearchId
39
39
$LogCount = ($SearchResults | Measure-Object ).Count
40
- Write-Warning " Logs to process: $LogCount "
40
+ $RunGuid = New-Guid
41
+ Write-Warning " Logs to process: $LogCount - RunGuid: $ ( $RunGuid ) - $ ( $TenantFilter ) "
41
42
$Results.TotalLogs = $LogCount
42
43
if ($LogCount -gt 0 ) {
43
44
$LocationTable = Get-CIPPTable - TableName ' knownlocationdb'
@@ -49,7 +50,7 @@ function Test-CIPPAuditLogRules {
49
50
$Data.CIPPExtendedProperties = ($Data.ExtendedProperties | ConvertTo-Json )
50
51
$Data.ExtendedProperties | ForEach-Object {
51
52
if ($_.Value -in $ExtendedPropertiesIgnoreList ) {
52
- Write-Warning " No need to process this operation as its in our ignore list. Some extended information: $ ( $data.operation ) :$ ( $_.Value ) - $ ( $TenantFilter ) "
53
+ # write-warning "No need to process this operation as its in our ignore list. Some extended information: $($data.operation):$($_.Value) - $($TenantFilter)"
53
54
continue
54
55
}
55
56
$Data | Add-Member - NotePropertyName $_.Name - NotePropertyValue $_.Value - Force - ErrorAction SilentlyContinue
@@ -68,12 +69,12 @@ function Test-CIPPAuditLogRules {
68
69
try {
69
70
$Data.ModifiedProperties | ForEach-Object { $Data | Add-Member - NotePropertyName " $ ( $_.Name ) " - NotePropertyValue " $ ( $_.NewValue ) " - Force - ErrorAction SilentlyContinue }
70
71
} catch {
71
- # write-warning ($Data.ModifiedProperties | ConvertTo-Json -Depth 10)
72
+ # # write-warning ($Data.ModifiedProperties | ConvertTo-Json -Depth 10)
72
73
}
73
74
try {
74
75
$Data.ModifiedProperties | ForEach-Object { $Data | Add-Member - NotePropertyName $ (" Previous_Value_$ ( $_.Name ) " ) - NotePropertyValue " $ ( $_.OldValue ) " - Force - ErrorAction SilentlyContinue }
75
76
} catch {
76
- # write-warning ($Data.ModifiedProperties | ConvertTo-Json -Depth 10)
77
+ # # write-warning ($Data.ModifiedProperties | ConvertTo-Json -Depth 10)
77
78
}
78
79
}
79
80
@@ -84,7 +85,7 @@ function Test-CIPPAuditLogRules {
84
85
# Check if IP is on trusted IP list
85
86
$TrustedIP = Get-CIPPAzDataTableEntity @TrustedIPTable - Filter " PartitionKey eq '$TenantFilter ' and RowKey eq '$ ( $Data.clientip ) ' and state eq 'Trusted'"
86
87
if ($TrustedIP ) {
87
- Write-Warning " IP $ ( $Data.clientip ) is trusted"
88
+ # write-warning "IP $($Data.clientip) is trusted"
88
89
$Trusted = $true
89
90
}
90
91
if (! $Trusted ) {
@@ -99,7 +100,7 @@ function Test-CIPPAuditLogRules {
99
100
try {
100
101
$Location = Get-CIPPGeoIPLocation - IP $Data.clientip
101
102
} catch {
102
- Write-Warning " Unable to get IP location for $ ( $Data.clientip ) : $ ( $_.Exception.Message ) "
103
+ # write-warning "Unable to get IP location for $($Data.clientip): $($_.Exception.Message)"
103
104
}
104
105
$Country = if ($Location.CountryCode ) { $Location.CountryCode } else { ' Unknown' }
105
106
$City = if ($Location.City ) { $Location.City } else { ' Unknown' }
@@ -120,7 +121,7 @@ function Test-CIPPAuditLogRules {
120
121
try {
121
122
$null = Add-CIPPAzDataTableEntity @LocationTable - Entity $LocationInfo - Force
122
123
} catch {
123
- Write-Warning " Failed to add location info for $ ( $Data.clientip ) to cache: $ ( $_.Exception.Message ) "
124
+ # write-warning "Failed to add location info for $($Data.clientip) to cache: $($_.Exception.Message)"
124
125
125
126
}
126
127
}
@@ -134,12 +135,12 @@ function Test-CIPPAuditLogRules {
134
135
}
135
136
$Data | Select-Object * - ExcludeProperty ExtendedProperties, DeviceProperties, parameters
136
137
} catch {
137
- Write-Warning " Audit log: Error processing data: $ ( $_.Exception.Message ) `r`n $ ( $_.InvocationInfo.PositionMessage ) "
138
+ # write-warning "Audit log: Error processing data: $($_.Exception.Message)`r`n$($_.InvocationInfo.PositionMessage)"
138
139
Write-LogMessage - API ' Webhooks' - message ' Error Processing Audit Log Data' - LogData (Get-CippException - Exception $_ ) - sev Error - tenant $TenantFilter
139
140
}
140
141
}
141
- Write-Warning " Processed Data: $ ( ($ProcessedData | Measure-Object ).Count) - This should be higher than 0 in many cases, because the where object has not run yet."
142
- Write-Warning " Creating filters - $ ( ($ProcessedData.operation | Sort-Object - Unique) -join ' ,' ) - $ ( $TenantFilter ) "
142
+ # write-warning "Processed Data: $(($ProcessedData | Measure-Object).Count) - This should be higher than 0 in many cases, because the where object has not run yet."
143
+ # write-warning "Creating filters - $(($ProcessedData.operation | Sort-Object -Unique) -join ',') - $($TenantFilter)"
143
144
144
145
$Where = $Configuration | ForEach-Object {
145
146
$conditions = $_.Conditions | ConvertFrom-Json | Where-Object { $_.Input.value -ne ' ' }
@@ -169,10 +170,10 @@ function Test-CIPPAuditLogRules {
169
170
170
171
$MatchedRules = [System.Collections.Generic.List [string ]]::new()
171
172
$DataToProcess = foreach ($clause in $Where ) {
172
- Write-Warning " Webhook: Processing clause: $ ( $clause.clause ) "
173
+ # write-warning "Webhook: Processing clause: $($clause.clause)"
173
174
$ReturnedData = $ProcessedData | Where-Object { Invoke-Expression $clause.clause }
174
175
if ($ReturnedData ) {
175
- Write-Warning " Webhook: There is matching data: $ ( ($ReturnedData.operation | Select-Object - Unique) -join ' , ' ) "
176
+ # write-warning "Webhook: There is matching data: $(($ReturnedData.operation | Select-Object -Unique) -join ', ')"
176
177
$ReturnedData = foreach ($item in $ReturnedData ) {
177
178
$item.CIPPAction = $clause.expectedAction
178
179
$item.CIPPClause = $clause.CIPPClause -join ' and '
@@ -186,5 +187,6 @@ function Test-CIPPAuditLogRules {
186
187
$Results.MatchedLogs = ($DataToProcess | Measure-Object ).Count
187
188
$Results.DataToProcess = $DataToProcess
188
189
}
190
+ Write-Warning " Finished - RunGuid: $ ( $RunGuid ) - $ ( $TenantFilter ) "
189
191
$Results
190
192
}
0 commit comments