Skip to content

Commit 0115569

Browse files
committed
Update Add-CIPPDbItem.ps1
1 parent d09601d commit 0115569

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

‎Modules/CIPPCore/Public/Add-CIPPDbItem.ps1‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,18 @@ function Add-CIPPDbItem {
4949
if ($null -eq $Item) { continue }
5050
$ItemId = $Item.ExternalDirectoryObjectId ?? $Item.id ?? $Item.Identity ?? $Item.skuId ?? $Item.userPrincipalName ?? [guid]::NewGuid().ToString()
5151
$RowKey = "$Type-$ItemId" -replace '[/\\#?]', '_' -replace '[\u0000-\u001F\u007F-\u009F]', ''
52-
[void]$NewRowKeys.Add($RowKey)
53-
$Batch.Add(@{
54-
PartitionKey = $TenantFilter
55-
RowKey = $RowKey
56-
Data = [string]($Item | ConvertTo-Json -Depth 10 -Compress)
57-
Type = $Type
58-
})
59-
if ($Batch.Count -ge 500) {
60-
$null = Add-CIPPAzDataTableEntity @Table -Entity $Batch.ToArray() -Force
61-
$TotalProcessed += $Batch.Count
62-
$Batch.Clear()
52+
if ($NewRowKeys.Add($RowKey)) {
53+
$Batch.Add(@{
54+
PartitionKey = $TenantFilter
55+
RowKey = $RowKey
56+
Data = [string]($Item | ConvertTo-Json -Depth 10 -Compress)
57+
Type = $Type
58+
})
59+
if ($Batch.Count -ge 500) {
60+
$null = Add-CIPPAzDataTableEntity @Table -Entity $Batch.ToArray() -Force
61+
$TotalProcessed += $Batch.Count
62+
$Batch.Clear()
63+
}
6364
}
6465
}
6566
}

0 commit comments

Comments
 (0)