Skip to content

Commit 091b973

Browse files
authored
Merge pull request #412 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 1006c6a + 495927c commit 091b973

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,28 @@ function New-BreachTenantSearch {
66
)
77

88
$Table = Get-CIPPTable -TableName UserBreaches
9-
$LatestBreach = Get-BreachInfo -TenantFilter $TenantFilter
9+
$LatestBreach = Get-BreachInfo -TenantFilter $TenantFilter | Group-Object -Property clientDomain
1010

1111
$usersResults = foreach ($domain in $LatestBreach) {
12-
$ExistingBreaches = Get-CIPPAzDataTableEntity @Table -Filter "RowKey eq '$TenantFilter'"
13-
if ($null -eq $domain.result) {
14-
Write-Host "No breaches found for domain $($domain.domain)"
12+
$ExistingBreaches = Get-CIPPAzDataTableEntity @Table -Filter "RowKey eq '$($domain.name)'"
13+
if ($null -eq $domain.Group) {
14+
Write-Host "No breaches found for domain $($domain.name)"
1515
continue
1616
}
17-
$SumOfBreaches = ($LatestBreach | Measure-Object -Sum -Property found).sum
18-
if ($ExistingBreaches.sum -eq $SumOfBreaches -and $Force.IsPresent -eq $false) {
19-
Write-Host "No new breaches found for tenant $TenantFilter"
20-
continue
17+
$SumOfBreaches = $domain.Count
18+
if ($ExistingBreaches.sum -eq $SumOfBreaches) {
19+
if ($Force.IsPresent -eq $true) {
20+
Write-Host "Forcing update for tenant $TenantFilter"
21+
} else {
22+
Write-Host "No new breaches found for tenant $TenantFilter"
23+
continue
24+
}
2125
}
2226

2327
@{
24-
RowKey = $domain.domain
28+
RowKey = $domain.name
2529
PartitionKey = $TenantFilter
26-
breaches = "$($LatestBreach.Result | ConvertTo-Json -Depth 10 -Compress)"
30+
breaches = "$($domain.Group | ConvertTo-Json -Depth 10 -Compress)"
2731
sum = $SumOfBreaches
2832
}
2933
}
@@ -32,7 +36,7 @@ function New-BreachTenantSearch {
3236
if ($usersResults) {
3337
try {
3438
$null = Add-CIPPAzDataTableEntity @Table -Entity $usersResults -Force
35-
return $LatestBreach.Result
39+
return $LatestBreach.Group
3640
} catch {
3741
Write-Error "Failed to add breaches to table: $($_.Exception.Message)"
3842
return $null

0 commit comments

Comments
 (0)