Skip to content

Commit b9ca96c

Browse files
committed
Refine NameOnly logic in Get-CIPPBackup
Updated the NameOnly parameter handling to filter out partitioned RowKeys and apply TenantFilter matching on RowKey when NameOnly is present. This improves the accuracy of backup name retrieval and ensures correct filtering based on tenant.
1 parent 74edf99 commit b9ca96c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Modules/CIPPCore/Public/Get-CIPPBackup.ps1

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,22 @@ function Get-CIPPBackup {
1818
}
1919

2020
if ($NameOnly.IsPresent) {
21-
$Table.Property = @('PartitionKey', 'RowKey', 'Timestamp', 'OriginalEntityId')
21+
$Table.Property = @('RowKey')
2222
}
2323

2424
$Filter = $Conditions -join ' and '
2525
$Table.Filter = $Filter
26-
$Info = Get-CIPPAzDataTableEntity @Table -Debug
27-
if ($TenantFilter) {
28-
$Info = $Info | Where-Object { $_.TenantFilter -eq $TenantFilter }
26+
$Info = Get-CIPPAzDataTableEntity @Table
27+
28+
if ($NameOnly.IsPresent) {
29+
$Info = $Info | Where-Object { $_.RowKey -notmatch '-part[0-9]+$' }
30+
if ($TenantFilter) {
31+
$Info = $Info | Where-Object { $_.RowKey -match "^$($TenantFilter)_" }
32+
}
33+
} else {
34+
if ($TenantFilter) {
35+
$Info = $Info | Where-Object { $_.TenantFilter -eq $TenantFilter }
36+
}
2937
}
3038
return $Info
3139
}

0 commit comments

Comments
 (0)