I am trying to build a script to retrieve the totalspace, freespace and freespace in percentage of a specific repo.
Basically I want to be able to put totalspace, freespace and freespace_percentage into three variables in order to pick those values up in nCentral.
I've searched the forum, found some examples, looked into the manuals for syntax help, but I'm not quite there.
Code: Select all
$repos = Get-VBRBackupRepository -Name "IMMUTABLE Backup Repository 1"
$repoReport = @()
foreach ($repo in $repos) {
$repo.GetContainer()
$totalSpace = $container.CachedTotalSpace
$totalFreeSpace = $container.CachedFreeSpace
$totalFreeSpaceProcent = $totalFreeSpace / $totalSpace * 100
$totalFreeSpaceProcentRounded = [Math]::Round($totalFreeSpaceProcent,1)
$repoReport += $repo | select Name, @{n='TotalSpace';e={$totalSpace}}, `
@{n='FreeSpace';e={$totalFreeSpace}}
}
$repoReport
$totalFreeSpaceProcentRounded
Code: Select all
PS C:\Windows\system32> $repos = Get-VBRBackupRepository -Name "IMMUTABLE Backup Repository 1"
PS C:\Windows\system32> $repoReport = @()
PS C:\Windows\system32> foreach ($repo in $repos) {
>> $repo.GetContainer()
>> $totalSpace = $container.CachedTotalSpace
>> $totalFreeSpace = $container.CachedFreeSpace
>> $totalFreeSpaceProcent = $totalFreeSpace / $totalSpace * 100
>> $totalFreeSpaceProcentRounded = [Math]::Round($totalFreeSpaceProcent,1)
>>
>> $repoReport += $repo | select Name, @{n='TotalSpace';e={$totalSpace}}, `
>> @{n='FreeSpace';e={$totalFreeSpace}}
>> }
Id : 1101d825-84ec-4f70-a4bf-71b38704eea8
Type : Default
CachedTotalSpace : 18,1 TB (19998980440064)
CachedFreeSpace : 2,87 TB (3158485389312)
UniqueKey : 1101D825-84EC-4F70-A4BF-71B38704EEA8
Info : Veeam.Backup.Model.CRepositoryContainerInfo
PS C:\Windows\system32> $repoReport
Name TotalSpace FreeSpace
---- ---------- ---------
IMMUTABLE Backup Repository 1 18,1 TB (19998980440064) 2,87 TB (3159579332608)
PS C:\Windows\system32> $totalFreeSpaceProcentRounded
15,8
PS C:\Windows\system32>
I'm using the foreach method, since using a separate line gave me the wrong repo, probably the default one, but the foreach does retrieve the correct info for the correct repo. If I just use the $totalSpace at the end, I get a whole list of all values, so that didn't help:
Code: Select all
PS C:\Windows\system32> $totalSpace
InBytes : 19998980440064
InKilobytes : 19530254336
InMegabytes : 19072514
InGigabytes : 18625
InTerabytes : 18
InPetabytes : 0
InBytesAsInt32 :
InKilobytesAsInt32 :
InMegabytesAsInt32 : 19072514
InGigabytesAsInt32 : 18625
InTerabytesAsInt32 : 18
InPetabytesAsInt32 : 0
InBytesAsUInt64 : 19998980440064
IsInvalid : False
Code: Select all
$reponame
IMMUTABLE Backup Repository 1
$TotalSpace
18
$FreeSpace
2
$totalFreeSpaceProcentRounded
15,8
Thanks in advance for any assistance you can give me.