Skip to content

Commit 1346baf

Browse files
author
rvdwegen
committed
Re-bulk listlogs
1 parent da6880c commit 1346baf

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Modules/CIPPCore/Public/Entrypoints/Invoke-ListLogs.ps1

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,42 @@ function Invoke-ListLogs {
2323
label = $_.PartitionKey
2424
}
2525
}
26+
} elseif ($Request.Query.logentryid) {
27+
# Return single log entry by RowKey
28+
$Filter = "RowKey eq '{0}'" -f $Request.Query.logentryid
29+
$AllowedTenants = Test-CIPPAccess -Request $Request -TenantList
30+
Write-Host "Getting single log entry for RowKey: $($Request.Query.logentryid)"
31+
32+
$Row = Get-AzDataTableEntity @Table -Filter $Filter
33+
34+
if ($Row) {
35+
if ($AllowedTenants -notcontains 'AllTenants') {
36+
$TenantList = Get-Tenants -IncludeErrors | Where-Object { $_.customerId -in $AllowedTenants }
37+
}
38+
39+
if ($AllowedTenants -contains 'AllTenants' -or ($AllowedTenants -notcontains 'AllTenants' -and ($TenantList.defaultDomainName -contains $Row.Tenant -or $Row.Tenant -eq 'CIPP' -or $TenantList.customerId -contains $Row.TenantId)) ) {
40+
$LogData = if ($Row.LogData -and (Test-Json -Json $Row.LogData -ErrorAction SilentlyContinue)) {
41+
$Row.LogData | ConvertFrom-Json
42+
} else { $Row.LogData }
43+
[PSCustomObject]@{
44+
DateTime = $Row.Timestamp
45+
Tenant = $Row.Tenant
46+
API = $Row.API
47+
Message = $Row.Message
48+
User = $Row.Username
49+
Severity = $Row.Severity
50+
LogData = $LogData
51+
TenantID = if ($Row.TenantID -ne $null) {
52+
$Row.TenantID
53+
} else {
54+
'None'
55+
}
56+
AppId = $Row.AppId
57+
IP = $Row.IP
58+
RowKey = $Row.RowKey
59+
}
60+
}
61+
}
2662
} else {
2763
if ($request.Query.Filter -eq 'True') {
2864
$LogLevel = if ($Request.Query.Severity) { ($Request.query.Severity).split(',') } else { 'Info', 'Warn', 'Error', 'Critical', 'Alert' }
@@ -86,6 +122,7 @@ function Invoke-ListLogs {
86122
}
87123
AppId = $Row.AppId
88124
IP = $Row.IP
125+
RowKey = $Row.RowKey
89126
}
90127
}
91128
}

0 commit comments

Comments
 (0)