PowerShell script exchange
Post Reply
Markus.K1985
Veeam Vanguard
Posts: 103
Liked: 28 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: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by oleg.feoktistov » 3 people like 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: 222
Liked: 51 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, Sr. Product Infrastructure Architect @iland / @1111systems, Veeam Vanguard
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
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 | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by oleg.feoktistov » 4 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 classes with "VBR" prefix under a separate namespace, which is usually Veeam.Backup.Powershell.Infos. Those classes 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: 103
Liked: 28 times
Joined: Dec 08, 2014 2:30 pm
Full Name: Markus Kraus
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by Markus.K1985 » 2 people like this post

Thank you all very much. This has helped a lot.
verk80
Lurker
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!
MJlee
Service Provider
Posts: 10
Liked: never
Joined: Jun 24, 2021 4:55 am
Full Name: Maojun Li
Contact:

[MERGED] can't retrieve the repository usage/capacity value from the new Veeam 11 powershell module

Post by MJlee »

I used to able to get the veeam repository total capacity and free space by running the following script by using the old Veeam powershell snapin. Since I upgraded to Veeam 11 and start using the new powershell module, the script doesn't work anymore.

#repo total space TB
[math]::Round( (Get-VBRBackupRepository -name $vrepo).info.CachedTotalspace/1099511627776,0)
#repo free space TB
[math]::Round( (Get-VBRBackupRepository -name $vrepo).info.CachedFreeSpace/1099511627776,1)

If you do `(Get-VBRBackupRepository -name $vrepo).info`, you can't see the CachedTotalspace and CachedFreeSpace object anymore.

Is there any other way I can retrieve the repository usage/capacity over powershell?
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by Natalia Lupacheva » 1 person likes this post

Hi @MJlee,

Moved your post to the existing thread to keep the similar issues together.
Please take a look at the reply and the discussions above.

Thanks!
tomhkr
Enthusiast
Posts: 42
Liked: 9 times
Joined: Feb 03, 2014 7:40 am
Contact:

Get repository size information?

Post by tomhkr »

With the old VeeamPSSnapin I used to run

Code: Select all

Get-VBRBackupRepository
and expand the Info parameter to get CachedTotalSpace and CachedFreeSpace

This no longer works since updating to V11 and the module-based Veeam.Backup.PowerShell. I get the respositories but the CachedTotalSpace and CachedFreeSpace are no longer under the Info parameter.

How is it supposed to work to fetch avaliable space on a repository in the new module based cmdlets?
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 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,

I merged your post with the existing thread. Please check the answers above.

Thanks,
Oleg
MartinO
Service Provider
Posts: 17
Liked: 4 times
Joined: Sep 24, 2020 9:09 am
Full Name: Martin Old
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by MartinO »

Is there any documentation for these new classes? I'm building out our documentation using the PS reference documentation but there's no mention of these classes and a quick Google doesn't bring anything up other than this thread.

I'm a bit of a newbie to this level of scripting so any reference material I can get my hands on would be brilliant!
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by oleg.feoktistov »

Hi Martin,

These are internal .NET classes, which are not officially supported. It means that you won't find any documenation on them, but a mention as a workaround only, usually in scope of our forum. So, in such cases this is a place to seek and ask.

Hope it clears things up.

Thanks,
Oleg
masonit
Service Provider
Posts: 325
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by masonit »

Hi!

Trying to get freespace from sobr extents (Get-VBRRepositoryExtent). There is no "GetContainer()" method for extents. Any workaround for this?

\Magnus
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by oleg.feoktistov »

Hi Magnus,

Yes, you need to access Repository property on extent to get to GetContainer() method. See an example in this post.

Best regards,
Oleg
masonit
Service Provider
Posts: 325
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: v11 - Get-VBRBackupRepository Space Properties

Post by masonit »

Ok, thanks.

Worked now. I tried to use GetContainer() on wrong property before..

\Magnus
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests