PowerShell script exchange
Post Reply
Markus.K1985
Veeam Vanguard
Posts: 93
Liked: 26 times
Joined: Dec 08, 2014 2:30 pm
Full Name: Markus Kraus
Contact:

v11 - Get-VBRBackupRepository Space Properties

Post by Markus.K1985 »

Hi,
some of my reporting scripts stopped working because of the missing Space Properties of the BackupRepository Object.

v10 Example:

Code: Select all

# Get All Backup Repositories Advanced
[Array]$RepoList = Get-VBRBackupRepository | Where-Object {$_.Type -ne "SanSnapshotOnly"} 
[Array]$ScaleOuts = Get-VBRBackupRepository -ScaleOut
if ($ScaleOuts) {
    foreach ($ScaleOut in $ScaleOuts) {
        $Extents = Get-VBRRepositoryExtent -Repository $ScaleOut
        foreach ($Extent in $Extents) {
            $RepoList = $RepoList + $Extent.repository
        }
    }
}
$RepoList | Select-Object Name, Path, `
@{Name="CachedTotalSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedTotalSpace/1GB,2)}}, `
@{Name="CachedFreeSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedFreeSpace/1GB,2)}} | Format-Table -AutoSize
Any recommendation for an alternative way to gather these details?

Best regards
Markus

oleg.feoktistov
Veeam Software
Posts: 904
Liked: 319 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by oleg.feoktistov » 1 person likes this post

Hi Markus,

These properties were moved to another class.
Here is the way to get them:

Code: Select all

$container = $extent.Repository.GetContainer()
$container.CachedFreeSpace
$container.CachedTotalSpace
Thanks,
Oleg

k00laid
Veeam Vanguard
Posts: 210
Liked: 46 times
Joined: Jan 13, 2011 5:42 pm
Full Name: Jim Jones
Location: Hurricane, WV
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by k00laid » 1 person likes this post

Hi Oleg,

I've got to ask, what is the rationale here? I'm working through using this and its if anything made the coding harder for standard usage. If I wanted to pull basic repo info in v10 I could do something like the following:

Code: Select all

Get-VBRBackupRepository | Select-Object Name, Id, @{n='PerVM';e={$PSItem.Options.OneBackupFilePerVm}},@{n='totalSpace';e={$PSItem.Info.CachedTotalSpace / 1TB}}, @{n='freeSpace';e={$PSItem.Info.CachedFreeSpace / 1TB}}
Now I need to wrap each of these items in a method statement to do the same.

Code: Select all

$Repos = get-vbrbackuprepository
$RepoDetails = foreach ($repo in $Repos) {
    [PSCustomObject]@{
        'Name'      = $Repo.Name
        'ID'        = $Repo.ID
        'Size'      = $Repo.GetContainer().CachedTotalSpace.InBytes / 1GB
        'FreeSpace' = $Repo.GetContainer().CachedFreeSpace.InBytes / 1GB
    }
} 
$RepoDetails
In the end you are just making it that much harder to consume data via powershell it seems. One liners go out the window for general day to day administration. Also I know I could have just specified .InGigabytes but standard practices die hard.
Jim Jones, Cloud Architect @iland, Veeam Vanguard

jhoughes
Veeam Software
Posts: 272
Liked: 108 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Austin, TX
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by jhoughes » 1 person likes this post

Also, specifying .InGigabytes will lead to some factor of rounding which is not as easily identifiable.

Jim, based on our conversation with your reporting against a very large number of repositories, the loss of that detail could also cause significant calculation issues, or real capacity issues over time.

I would still suggest using the most accurate form of the detail data, and only perform the rounding as you are comfortable with for easily reporting in a visible fashion; this still gives you the capability of staying entirely granular as needed.
Husband, Father, Solutions Architect, Geek Extraordinaire | @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion

oleg.feoktistov
Veeam Software
Posts: 904
Liked: 319 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by oleg.feoktistov » 2 people like this post

Hi Jim,

Some older cmdlets like Get-VBRBackupRepository, Get-VBRJob, Get-VBRBackupSession etc. return objects of core classes (those with "C" prefix). When implementing new cmdlets now, we avoid this practice and stick to placing new objects with "VBR" prefix under a separate namespace, which is usually Veeam.Backup.Powershell.Infos. Those objects have fixed properties and keep references to internal classes to a minimum. Core classes are great and often very informative, but, in fact, they are more related to C# and .NET than to Powershell. Their methods and properties can be used in different parts of the code. So, if business logic changes, it may lead to properties/method relocation or else. This is what you've encountered.
Now, I'm not fully aware of why these particular properties were moved, but I do see that it is related to platform integration.
So, no rationale here. Core classes just don't have one if it comes to API contract compliance.
I do believe, though, that sooner or later we'll be able to wrap them all in VBR* classes, and I'll start sleeping at night.

Kind regards,
Oleg

Markus.K1985
Veeam Vanguard
Posts: 93
Liked: 26 times
Joined: Dec 08, 2014 2:30 pm
Full Name: Markus Kraus
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by Markus.K1985 » 1 person likes this post

Thank you all very much. This has helped a lot.

verk80
Service Provider
Posts: 1
Liked: 1 time
Joined: Apr 07, 2020 1:18 pm
Full Name: Tyler Verkade
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by verk80 » 1 person likes this post

Hey guys, thank you for the clarification on this from me as well. I had created some reports that weren't working since the upgrade to v11, and I knew the info wasn't in the right place anymore, but I wasn't able to find it. I greatly appreciate it!

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests