Created
November 27, 2024 08:47
-
-
Save cuongitl/5f412b0dffa9f899be7c484f910a1410 to your computer and use it in GitHub Desktop.
Powershell: getVeeam Backup & Replication's Repository Information
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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