Skip to content

Instantly share code, notes, and snippets.

@cuongitl
Created November 27, 2024 08:47
Show Gist options
  • Select an option

  • Save cuongitl/5f412b0dffa9f899be7c484f910a1410 to your computer and use it in GitHub Desktop.

Select an option

Save cuongitl/5f412b0dffa9f899be7c484f910a1410 to your computer and use it in GitHub Desktop.
Powershell: getVeeam Backup & Replication's Repository Information
# Veeam: Powershell get Backup Repository Information: Returns a list of backup repositories.
# version 02
# Define the function
function Get-VBRBackupRepositoryDetails {
$Repos = Get-VBRBackupRepository
$RepoDetails = foreach ($repo in $Repos) {
[PSCustomObject]@{
'Name' = $repo.Name
'ID' = $repo.ID
'Type' = if ($repo.Type -is [Enum]) {
$repo.Type.ToString()
} elseif ($repo.Type -is [int]) {
switch ($repo.Type) {
0 { "LocalRepository" }
1 { "CloudRepository" }
2 { "NetworkRepository" }
3 { "BackupRepository" }
default { "Unknown" }
}
} else {
"Unknown ($($repo.Type))"
}
'Path' = $repo.Path.ToString() # Ensure it returns as a string
'Capacity' = $repo.GetContainer().CachedTotalSpace.InBytes / 1GB
'FreeSpace' = $repo.GetContainer().CachedFreeSpace.InBytes / 1GB
}
}
# Return the details as JSON
return $RepoDetails | ConvertTo-Json -Depth 3
}
# Call the function and output the result
Get-VBRBackupRepositoryDetails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment