-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathNew-CloudBinReport.ps1
52 lines (46 loc) · 1.96 KB
/
New-CloudBinReport.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Add-PSSnapin -Name VeeamPSSnapin
function New-CloudBinReport
{
$report = New-Object -TypeName System.Collections.Generic.List[PSCustomObject]
$tenants = Get-VBRCloudTenant
foreach ($tenant in $tenants)
{
if ($tenant.ResourcesEnabled)
{
$tenantQuota = [Veeam.Backup.Core.CTenantQuota]::DbFindByTenantId($tenant.Id)
if ($tenantQuota.CachedRepository.Type -eq "ExtendableRepository")
{
$binSize = 0
$extents = $tenantQuota.CachedRepository.GetExtents()
foreach ($extent in $extents)
{
$binPath = [Veeam.Backup.Model.SPathConverter]::RepositoryPathToString(
$extent.FullPath.Combine(
[Veeam.Backup.Common.CPartialPath]$tenantQuota.AbsoluteRecycleBinPath
),
$extent.Type
)
$repoAccessor = [Veeam.Backup.Core.CRepositoryAccessorFactory]::Create($extent)
$binSize += $repoAccessor.FileCommander.GetDirSize($binPath)
}
}
else
{
$binPath = [Veeam.Backup.Model.SPathConverter]::RepositoryPathToString(
$tenantQuota.AbsoluteRecycleBinPath,
$tenantQuota.CachedRepository.Type
)
$repoAccessor = [Veeam.Backup.Core.CRepositoryAccessorFactory]::Create($tenantQuota.CachedRepository)
$binSize = $repoAccessor.FileCommander.GetDirSize($binPath)
}
$tenantReport = [PSCustomObject]@{
tenantName = $tenant.Name;
binSize = $binSize
}
$report.Add($tenantReport)
}
}
return $report
}
New-CloudBinReport | Format-Table -Property @{Expression={$_.tenantName}; Label="Tenant"},
@{Expression={[System.Math]::Round($_.binSize / 1GB, 2)}; Label="Bin size (GB)"}