Skip to content

Commit e39cb31

Browse files
Backup in tenant overview information
1 parent 72c4d46 commit e39cb31

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using namespace System.Net
22

3-
Function Invoke-ExecListBackup {
3+
function Invoke-ExecListBackup {
44
<#
55
.FUNCTIONALITY
66
Entrypoint
@@ -20,29 +20,25 @@ Function Invoke-ExecListBackup {
2020
$BackupName = $Request.Query.BackupName
2121

2222
$CippBackupParams = @{}
23-
if ($Type) {
24-
$CippBackupParams.Type = $Type
25-
}
26-
if ($TenantFilter) {
27-
$CippBackupParams.TenantFilter = $TenantFilter
28-
}
29-
if ($NameOnly) {
30-
$CippBackupParams.NameOnly = $true
31-
}
32-
if ($BackupName) {
33-
$CippBackupParams.Name = $BackupName
34-
}
23+
if ($Type) { $CippBackupParams.Type = $Type }
24+
if ($TenantFilter) { $CippBackupParams.TenantFilter = $TenantFilter }
25+
if ($BackupName) { $CippBackupParams.Name = $BackupName }
3526

3627
$Result = Get-CIPPBackup @CippBackupParams
3728

3829
if ($NameOnly) {
39-
$Result = $Result | Select-Object @{Name = 'BackupName'; exp = { $_.RowKey } }, Timestamp | Sort-Object Timestamp -Descending
30+
$Processed = foreach ($item in $Result) {
31+
$properties = $item.PSObject.Properties | Where-Object { $_.Name -notin @('TenantFilter', 'ETag', 'PartitionKey', 'RowKey', 'Timestamp') -and $_.Value }
32+
[PSCustomObject]@{
33+
BackupName = $item.RowKey
34+
Timestamp = $item.Timestamp
35+
Items = $properties.Name
36+
}
37+
}
38+
$Result = $Processed | Sort-Object Timestamp -Descending
4039
}
41-
42-
# Associate values to output bindings by calling 'Push-OutputBinding'.
4340
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
4441
StatusCode = [HttpStatusCode]::OK
4542
Body = @($Result)
4643
})
47-
4844
}

Modules/CIPPCore/Public/Get-CIPPBackup.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ function Get-CIPPBackup {
66
[string]$Name,
77
[switch]$NameOnly
88
)
9+
910
Write-Host "Getting backup for $Type with TenantFilter $TenantFilter"
1011
$Table = Get-CippTable -tablename "$($Type)Backup"
1112

1213
$Conditions = [System.Collections.Generic.List[string]]::new()
1314
$Conditions.Add("PartitionKey eq '$($Type)Backup'")
1415

15-
if ($TenantFilter) {
16-
$Conditions.Add("TenantFilter eq '$($TenantFilter)'")
17-
}
1816
if ($Name) {
1917
$Conditions.Add("RowKey eq '$($Name)' or OriginalEntityId eq '$($Name)'")
2018
}
@@ -25,7 +23,9 @@ function Get-CIPPBackup {
2523

2624
$Filter = $Conditions -join ' and '
2725
$Table.Filter = $Filter
28-
29-
$Info = Get-CIPPAzDataTableEntity @Table
30-
return $info
26+
$Info = Get-CIPPAzDataTableEntity @Table -Debug
27+
if ($TenantFilter) {
28+
$Info = $Info | Where-Object { $_.TenantFilter -eq $TenantFilter }
29+
}
30+
return $Info
3131
}

0 commit comments

Comments
 (0)