@@ -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