Skip to content

Commit 8afba87

Browse files
authored
Merge pull request #285 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents e01191f + 48920ad commit 8afba87

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

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

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using namespace System.Net
33
function Invoke-ListLogs {
44
<#
55
.FUNCTIONALITY
6-
Entrypoint
6+
Entrypoint,AnyTenant
77
.ROLE
88
CIPP.Core.Read
99
#>
@@ -54,35 +54,34 @@ function Invoke-ListLogs {
5454
Write-Host "Getting logs for filter: $Filter, LogLevel: $LogLevel, Username: $username"
5555

5656
$Rows = Get-AzDataTableEntity @Table -Filter $Filter | Where-Object { $_.Severity -in $LogLevel -and $_.Username -like $username }
57+
58+
if ($AllowedTenants -notcontains 'AllTenants') {
59+
$TenantList = Get-Tenants -IncludeErrors | Where-Object { $_.customerId -in $AllowedTenants }
60+
}
61+
5762
foreach ($Row in $Rows) {
58-
if ($AllowedTenants -notcontains 'AllTenants') {
59-
$TenantList = Get-Tenants -IncludeErrors
60-
if ($Row.Tenant -ne 'None' -and $Row.Tenant) {
61-
$Tenant = $TenantList | Where-Object -Property defaultDomainName -EQ $Row.Tenant
62-
if ($Tenant -and $Tenant.customerId -notin $AllowedTenants) {
63-
continue
63+
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)) ) {
64+
65+
$LogData = if ($Row.LogData -and (Test-Json -Json $Row.LogData -ErrorAction SilentlyContinue)) {
66+
$Row.LogData | ConvertFrom-Json
67+
} else { $Row.LogData }
68+
[PSCustomObject]@{
69+
DateTime = $Row.Timestamp
70+
Tenant = $Row.Tenant
71+
API = $Row.API
72+
Message = $Row.Message
73+
User = $Row.Username
74+
Severity = $Row.Severity
75+
LogData = $LogData
76+
TenantID = if ($Row.TenantID -ne $null) {
77+
$Row.TenantID
78+
} else {
79+
'None'
6480
}
81+
AppId = $Row.AppId
82+
IP = $Row.IP
6583
}
6684
}
67-
$LogData = if ($Row.LogData -and (Test-Json -Json $Row.LogData -ErrorAction SilentlyContinue)) {
68-
$Row.LogData | ConvertFrom-Json
69-
} else { $Row.LogData }
70-
[PSCustomObject]@{
71-
DateTime = $Row.Timestamp
72-
Tenant = $Row.Tenant
73-
API = $Row.API
74-
Message = $Row.Message
75-
User = $Row.Username
76-
Severity = $Row.Severity
77-
LogData = $LogData
78-
TenantID = if ($Row.TenantID -ne $null) {
79-
$Row.TenantID
80-
} else {
81-
'None'
82-
}
83-
AppId = $Row.AppId
84-
IP = $Row.IP
85-
}
8685
}
8786
}
8887

0 commit comments

Comments
 (0)