Skip to content

Commit 9846930

Browse files
add autocleanup
1 parent f28596a commit 9846930

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Modules/CIPPCore/Public/Add-CIPPDbItem.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ function Add-CIPPDbItem {
4242

4343
try {
4444
$Table = Get-CippTable -tablename 'CippReportingDB'
45+
#Get the existing type entries and nuke them. This ensures we don't have stale data.
46+
$Filter = "PartitionKey eq '{0}' and RowKey ge '{1}-' and RowKey lt '{1}0'" -f $TenantFilter, $Type
47+
$ExistingEntities = Get-CIPPAzDataTableEntity @Table -Filter $Filter
48+
if ($ExistingEntities) {
49+
Remove-AzDataTableEntity @Table -Entity $ExistingEntities -Force | Out-Null
50+
}
4551

4652
if ($Count) {
4753
$Entity = @{
@@ -54,7 +60,7 @@ function Add-CIPPDbItem {
5460

5561
} else {
5662
$Entities = foreach ($Item in $Data) {
57-
$ItemId = $Item.id
63+
$ItemId = $Item.id ? $Item.id : $item.skuId
5864
@{
5965
PartitionKey = $TenantFilter
6066
RowKey = "$Type-$ItemId"

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Invoke-ListTests.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ function Invoke-ListTests {
121121
$TestResultsData | Add-Member -NotePropertyName 'MFAState' -NotePropertyValue $MFAStateData -Force
122122
}
123123

124+
$LicenseData = New-CIPPDbRequest -TenantFilter $TenantFilter -Type 'LicenseOverview'
125+
if ($LicenseData) {
126+
$TestResultsData | Add-Member -NotePropertyName 'LicenseData' -NotePropertyValue @($LicenseData) -Force
127+
}
128+
124129
$StatusCode = [HttpStatusCode]::OK
125130
$Body = $TestResultsData
126131

Modules/CIPPCore/Public/Get-CIPPDbItem.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ function Get-CIPPDbItem {
5555
throw
5656
}
5757
}
58+

0 commit comments

Comments
 (0)