Skip to content

Commit ed4a93a

Browse files
authored
Merge pull request #378 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents b422922 + ca57d38 commit ed4a93a

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

Modules/CIPPCore/Public/AuditLogs/New-CippAuditLogSearch.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function New-CippAuditLogSearch {
125125
)
126126

127127
$SearchParams = @{
128-
displayName = 'CIPP Audit Search - ' + (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')
128+
displayName = $DisplayName
129129
filterStartDateTime = $StartTime.ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss')
130130
filterEndDateTime = $EndTime.AddHours(1).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss')
131131
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Administration/Alerts/Invoke-ExecAuditLogSearch.ps1

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ function Invoke-ExecAuditLogSearch {
2828
return
2929
}
3030

31+
# Convert StartTime and EndTime to DateTime from unixtime
32+
if ($Query.StartTime -match '^\d+$') {
33+
$Query.StartTime = [DateTime]::UnixEpoch.AddSeconds([long]$Query.StartTime)
34+
} else {
35+
$Query.StartTime = [DateTime]$Query.StartTime
36+
}
37+
38+
if ($Query.EndTime -match '^\d+$') {
39+
$Query.EndTime = [DateTime]::UnixEpoch.AddSeconds([long]$Query.EndTime)
40+
} else {
41+
$Query.EndTime = [DateTime]$Query.EndTime
42+
}
43+
3144
$Command = Get-Command New-CippAuditLogSearch
3245
$AvailableParameters = $Command.Parameters.Keys
3346
$BadProps = foreach ($Prop in $Query.PSObject.Properties.Name) {
@@ -44,8 +57,23 @@ function Invoke-ExecAuditLogSearch {
4457
}
4558

4659
try {
60+
Write-Information "Executing audit log search with parameters: $($Query | ConvertTo-Json -Depth 10)"
61+
4762
$Query = $Query | ConvertTo-Json -Depth 10 | ConvertFrom-Json -AsHashtable
48-
$Results = New-CippAuditLogSearch @Query
63+
$NewSearch = New-CippAuditLogSearch @Query
64+
65+
if ($NewSearch) {
66+
$Results = @{
67+
resultText = "Created audit log search: $($NewSearch.displayName)"
68+
state = 'success'
69+
details = $NewSearch
70+
}
71+
} else {
72+
$Results = @{
73+
resultText = 'Failed to initiate search'
74+
state = 'error'
75+
}
76+
}
4977
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
5078
StatusCode = [HttpStatusCode]::OK
5179
Body = $Results

Modules/CIPPCore/Public/Get-CIPPTenantCapabilities.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ function Get-CIPPTenantCapabilities {
2121
}
2222
Add-CIPPAzDataTableEntity @ConfigTable -Entity $Entity -Force
2323
}
24-
$Plans = $Org.servicePlans | Where-Object { $_.provisioningStatus -eq 'Success' -or $_.provisioningStatus -eq 'PendingInput' } | Sort-Object -Property serviceplanName -Unique | Select-Object servicePlanName, provisioningStatus
24+
$Plans = $Org.servicePlans | Where-Object { $_.provisioningStatus -ne 'disabled' } | Sort-Object -Property serviceplanName -Unique | Select-Object servicePlanName, provisioningStatus
2525
$Results = @{}
2626
foreach ($Plan in $Plans) {
27-
$Results."$($Plan.servicePlanName)" = $Plan.provisioningStatus -eq 'Success' -or $Plan.provisioningStatus -eq 'PendingInput'
27+
$Results."$($Plan.servicePlanName)" = $Plan.provisioningStatus -ne 'disabled'
2828
}
2929
[PSCustomObject]$Results
3030
}

Modules/CippExtensions/Public/HIBP/New-BreachTenantSearch.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ function New-BreachTenantSearch {
3030

3131
#Add user breaches to table
3232
if ($usersResults) {
33-
$entity = Add-CIPPAzDataTableEntity @Table -Entity $usersResults -Force
34-
return $LatestBreach.Result
33+
try {
34+
$null = Add-CIPPAzDataTableEntity @Table -Entity $usersResults -Force
35+
return $LatestBreach.Result
36+
} catch {
37+
Write-Error "Failed to add breaches to table: $($_.Exception.Message)"
38+
return $null
39+
}
3540
}
3641
}

0 commit comments

Comments
 (0)