Closed DamageDoctor closed 4 years ago
Hi @DamageDoctor ,
might you please share some details about your environment?
$PSVersionTable
You should check first to see if it's a general problem:
$PSVersionTable
.\PSx64.exe -f="TEST-Script.ps1"
OS=Windows 2012 R2 PSVersion=4.0 PSx64.exe=18.1.1
Seems to only be an issue with the PRTG Veeam script as per your suggested test:
PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> .\PSx64.exe -f="TEST-Script.ps1"
0:
Name Value
---- -----
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.42000
BuildVersion 6.3.9600.19170
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2
Do you use the latest version of the script from the Repo?
I was not able to reproduce the same environment. With Windows 2019, PowerShell 5.1 and the same PSx64.exe version does it work fine.
PS C:\temp> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.316
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.316
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\temp> .\PSx64.exe -f="PRTG-VeeamBRStats.ps1"
Thanks for the quick reply. I copied the latest raw code from the repo and tried again.
PSx64 run gives the following output:
PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> .\PSx64.exe -f="PRTG-VeeamBRStats.ps1" -p="-BRHost
xxxxxxxxx.xxxxxx.xxx"
C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\PRTG-VeeamBRStats.ps1 : Failed to connect to Veeam
BR Host
At line:1 char:1
+ &'C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\PRTG-VeeamBR ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,PRTG-VeeamBRStats.ps1
C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\PRTG-VeeamBRStats.ps1 : at <ScriptBlock>, C:\Program
Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\PRTG-VeeamBRStats.ps1: line 202
at <ScriptBlock>, <No file>: line 1
At line:1 char:1
+ &'C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\PRTG-VeeamBR ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,PRTG-VeeamBRStats.ps1
<prtg>
<error>1</error>
<text>Failed to connect to Veeam BR Host</text>
</prtg>
Running the script on its own in a x64 PS window sort of works. I get some XML results back and then:
<result>
<channel>Running-Endpoints</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\PRTG-VeeamBRStats.ps1 : You cannot call a method on
a null-valued expression.
At line:1 char:1
+ .\PRTG-VeeamBRStats.ps1 -BRHost xxxxxxxxx.xxxxxx.xxx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,PRTG-VeeamBRStats.ps1
C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\PRTG-VeeamBRStats.ps1 : at Get-vPCRepoInfo<Process>,
C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\PRTG-VeeamBRStats.ps1: line 168
at <ScriptBlock>, C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\PRTG-VeeamBRStats.ps1: line 509
at <ScriptBlock>, <No file>: line 1
At line:1 char:1
+ .\PRTG-VeeamBRStats.ps1 -BRHost xxxxxxxxx.xxxxxx.xxx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,PRTG-VeeamBRStats.ps1
<prtg>
<error>1</error>
<text>You cannot call a method on a null-valued expression.</text>
</prtg>
Further to this. Updated PS to 5.1 on 2012 R2 and same issue.
PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> .\PSx64.exe -f="TEST-Script.ps1"
0:
Name Value
---- -----
PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
The usage of parameters with PSx64.exe is a bit tricky. You can modify the scripts the Default Server to your environment (currently localhost) or try this syntax if you only need one parameter: -f=“PRTG-VeeamBRStats.ps1″ -p=“Veeam01.lan.local“
.
The second Error looks like a problem with one of your backup repositories. Might you please share the return of this command:
Get-VBRBackupRepository | select name, type | ft -AutoSize
Changing the PSx64 parameter to remove BRHost worked and it now connects to the server correctly.
Here is the output as requested:
PS C:\Users\administrator> Add-PSSnapin VeeamPSSnapin
PS C:\Users\administrator> Get-VBRBackupRepository | select name, type | ft -AutoSize
Name Type
---- ----
Interactive Cloud Repository Cloud
Backup Repository (Configuration) CifsShare
Backup Repository (MA1_1) WinLocal
Backup Repository 1 (REP01) WinLocal
Could it be anything to do with using a scale out repository?
Sounds good.
I think for the second problem I have already a workaround. Other users also reported a problem with cloud Repositories, but I was not able to merge the workaround into the master branch because of missing testers.
Please try this version of the script: https://github.com/mycloudrevolution/Advanced-PRTG-Sensors/blob/ExcludeCloudRepos/Veeam/PRTG-VeeamBRStats.ps1
You can also run the script in debug mode to get a human-readable summary at the end:
C:\temp\PRTG-VeeamBRStats.ps1 -Debug
This workaround excludes Cloud Repositories from the report. If you are willing in supporting me to create a fix that also includes Cloud Repositories (I currently do not have access to this type of Repositories) you can run this snippet and paste the result:
[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, @{Name="CachedTotalSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedTotalSpace/1GB,2)}}, @{Name="CachedFreeSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedFreeSpace/1GB,2)}} | Format-Table -AutoSize
New script version worked! Thanks.
Happy to support / assist with the development where I can. Results below.
PS C:\Scripts> [Array]$RepoList = Get-VBRBackupRepository | Where-Object {$_.Type -ne "SanSnapshotOnly"}
PS C:\Scripts> [Array]$ScaleOuts = Get-VBRBackupRepository -ScaleOut
PS C:\Scripts> if ($ScaleOuts) {
>> foreach ($ScaleOut in $ScaleOuts) {
>> $Extents = Get-VBRRepositoryExtent -Repository $ScaleOut
>> foreach ($Extent in $Extents) {
>> $RepoList = $RepoList + $Extent.repository
>> }
>> }
>> }
>> $RepoList | Select-Object Name, @{Name="CachedTotalSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedTotalS
pace/1GB,2)}}, @{Name="CachedFreeSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedFreeSpace/1GB,2)}} | Format
-Table -AutoSize
>>
Name CachedTotalSpaceGB CachedFreeSpaceGB
---- ------------------ -----------------
Interactive Cloud Repository 0.00 0.00
Backup Repository (Configuration) 40.00 24.30
Backup Repository 1 (REP01) 8373.5 3278.97
Backup Repository (MA1_2) 50287.12 20962.78
Unfortunately, there is no documentation for the Repository object. So, we need to compare the two different types.
Get Info and Vars:
[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, @{Name="CachedTotalSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedTotalSpace/1GB,2)}}, @{Name="CachedFreeSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedFreeSpace/1GB,2)}} | Format-Table -AutoSize
Cloud Repo:
$RepoList | Where { $_.Name -match "Interactive Cloud Repository"} | Select *
$RepoList | Where { $_.Name -match "Interactive Cloud Repository"} | Get-Member
SMB Repo:
$RepoList | Where { $_.Name -match "Backup Repository (Configuration)"} | Select *
$RepoList | Where { $_.Name -match "Backup Repository (Configuration)"} | Get-Member
I must be missing something with those repo lines as I just get prompted for more PS
>> $RepoList | Where { $_.Name -match "Backup Repository (Configuration)" | Select *
>> $RepoList | Where { $_.Name -match "Backup Repository (Configuration)" | Get-Member
>>
>>
Sorry, I have corrected the code snippet.
Some identifiable data stripped out.
PS C:\Scripts> $RepoList | Where { $_.Name -match "Interactive Cloud Repository"} | Select *
CloudId : 68d691b8-077a-4eaa-ab7a-aace24c4bf60
ProviderId : a43d63fb-2eab-4564-beab-bbceff59d25b
IsAvailable : True
IsWanAcceleratorEnabled : False
CloudProvider : xxxxxx,xxxxxx,xxxxxx
Path :
FullPath :
Info : Veeam.Backup.Model.CCloudRepositoryInfo
Id : cf030942-4f66-4993-953d-6da2cc3655f1
Name : Interactive Cloud Repository
HostId : ee9388dd-0d7a-4c76-a338-fee86081005b
MountHostId : ee9388dd-0d7a-4c76-a338-fee86081005b
Description : Cloud repository
CreationTime :
FriendlyPath : \XXXXXXXXX
ShareCredsId : 00000000-0000-0000-0000-000000000000
Type : Cloud
Status : Ordinal
Group : BackupRepository
UseNfsOnMountHost : False
VersionOfCreation : 9.5.4.2753
IsReadOnly : False
IsTemporary : False
TypeDisplay : Cloud
IsRotatedDriveRepository : False
EndPointCryptoKeyId : 00000000-0000-0000-0000-000000000000
Options : Veeam.Backup.Model.CDomBackupRepositoryOptions
HasBackupChainLengthLimitation : False
IsSanSnapshotOnly : False
IsDedupStorage : False
SplitStoragesPerVm : True
PS C:\Scripts> $RepoList | Where { $_.Name -match "Interactive Cloud Repository"} | Get-Member
TypeName: Veeam.Backup.Core.CCloudRepository
Name MemberType Definition
---- ---------- ----------
ChangeAvailability Method void ChangeAvailability(bool value)
CombinePath Method Veeam.Backup.Common.CLegacyPath CombinePath(string name), Veeam.Backu...
CreateRotatedDrive Method Veeam.Backup.Core.CRotatedDrive CreateRotatedDrive(string volumeGuid,...
Delete Method void Delete()
Equals Method bool Equals(Veeam.Backup.Core.CBackupRepository other), bool Equals(S...
FindDbShareCreds Method Veeam.Backup.Core.CDbCredentials FindDbShareCreds(), Veeam.Backup.Cor...
FindEndPointCryptoKey Method Veeam.Backup.Core.CCryptoKey FindEndPointCryptoKey()
FindHost Method Veeam.Backup.Core.Common.CHost FindHost(), Veeam.Backup.Core.Common.C...
FindMountHost Method Veeam.Backup.Core.Common.CHost FindMountHost(Veeam.Backup.Core.COib o...
FindRotatedDriveByVolumeGuid Method Veeam.Backup.Core.CRotatedDrive FindRotatedDriveByVolumeGuid(string v...
FindShareCreds Method Veeam.Backup.Common.CCredentials FindShareCreds(), Veeam.Backup.Commo...
GetBackups Method Veeam.Backup.Core.CBackup[] GetBackups(bool skipImported, bool skipEn...
GetEndPointBackups Method Veeam.Backup.Core.CBackup[] GetEndPointBackups(bool skipImported, boo...
GetHashCode Method int GetHashCode()
GetHost Method Veeam.Backup.Core.Common.CHost GetHost(), Veeam.Backup.Core.Common.CH...
GetMaxBackupChainLength Method int GetMaxBackupChainLength(), int IBackupRepository.GetMaxBackupChai...
GetMountHost Method Veeam.Backup.Core.Common.CHost GetMountHost(Veeam.Backup.Core.COib oib)
GetRotatedDrives Method System.Collections.Generic.IEnumerable[Veeam.Backup.Core.CRotatedDriv...
GetType Method type GetType()
HasCustomSecurityOptions Method bool HasCustomSecurityOptions()
IsChild Method bool IsChild()
IsCifsShare Method bool IsCifsShare(), bool IBackupRepository.IsCifsShare()
IsCifsShareWithCreds Method bool IsCifsShareWithCreds()
IsDeletionAllowed Method bool IsDeletionAllowed([ref] string error)
IsHostOverridable Method bool IsHostOverridable(), bool IBackupRepository.IsHostOverridable()
IsHostSpecified Method bool IsHostSpecified(), bool IBackupRepository.IsHostSpecified()
IsMaintanceMode Method bool IsMaintanceMode()
IsPublicPluginRepository Method bool IsPublicPluginRepository()
IsRepositoryUsedByVcWorkspaceConfig Method bool IsRepositoryUsedByVcWorkspaceConfig()
IsUsedByVcdOrgConfig Method bool IsUsedByVcdOrgConfig()
ReloadOptions Method void ReloadOptions(bool oneBackupFilePerVm)
SaveOptions Method void SaveOptions(), void IBackupRepository.SaveOptions()
SerializeOptions Method void SerializeOptions()
SetStatus Method void SetStatus(Veeam.Backup.Model.CBackupRepositoryInfo+EStatus status)
SetUnavailable Method void SetUnavailable()
ToCloudRepository Method Veeam.Backup.Core.CCloudRepository ToCloudRepository()
ToLogLine Method string ToLogLine(), string IBackupRepository.ToLogLine()
ToString Method string ToString()
Update Method void Update(string name, Veeam.Backup.Model.CBackupRepositoryInfo+ETy...
UpdateSpaceInfo Method void UpdateSpaceInfo(long totalSpace, long freeSpace), void IBackupRe...
CloudId Property guid CloudId {get;}
CloudProvider Property Veeam.Backup.Core.CCloudProvider CloudProvider {get;}
CreationTime Property System.Nullable[datetime] CreationTime {get;}
Description Property string Description {get;}
EndPointCryptoKeyId Property guid EndPointCryptoKeyId {get;}
FriendlyPath Property string FriendlyPath {get;}
FullPath Property Veeam.Backup.Common.CFullPath FullPath {get;}
Group Property Veeam.Backup.Model.ERepositoryGroup Group {get;}
HasBackupChainLengthLimitation Property bool HasBackupChainLengthLimitation {get;}
HostId Property guid HostId {get;}
Id Property guid Id {get;}
Info Property Veeam.Backup.Model.CBackupRepositoryInfo Info {get;}
IsAvailable Property bool IsAvailable {get;}
IsDedupStorage Property bool IsDedupStorage {get;}
IsReadOnly Property bool IsReadOnly {get;}
IsRotatedDriveRepository Property bool IsRotatedDriveRepository {get;}
IsSanSnapshotOnly Property bool IsSanSnapshotOnly {get;}
IsTemporary Property bool IsTemporary {get;}
IsWanAcceleratorEnabled Property bool IsWanAcceleratorEnabled {get;}
MountHostId Property guid MountHostId {get;}
Name Property string Name {get;}
Options Property Veeam.Backup.Model.CDomBackupRepositoryOptions Options {get;}
Path Property Veeam.Backup.Common.CLegacyPath Path {get;}
ProviderId Property guid ProviderId {get;}
ShareCredsId Property guid ShareCredsId {get;}
SplitStoragesPerVm Property bool SplitStoragesPerVm {get;}
Status Property Veeam.Backup.Model.CBackupRepositoryInfo+EStatus Status {get;}
Type Property Veeam.Backup.Model.CBackupRepositoryInfo+EType Type {get;}
TypeDisplay Property string TypeDisplay {get;}
UseNfsOnMountHost Property bool UseNfsOnMountHost {get;}
VersionOfCreation Property version VersionOfCreation {get;}
PS C:\Scripts> $RepoList | Where { $_.Name -match "Backup Repository (Configuration)"} | Select *
PS C:\Scripts> $RepoList | Where { $_.Name -match "Backup Repository (Configuration)"} | Get-Member
Get-Member : You must specify an object for the Get-Member cmdlet.
At line:1 char:75
+ ... re { $_.Name -match "Backup Repository (Configuration)"} | Get-Member
+ ~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-Member], InvalidOperationException
+ FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand
Okay, we need to dig a little bit deeper into the "Veeam.Backup.Core.CCloudRepository" Object :
($RepoList | Where { $_.Name -match "Interactive Cloud Repository"}).info | Select *
PS C:\Scripts> ($RepoList | Where { $_.Name -match "Interactive Cloud Repository"}).info | Select *
ProviderId : a43d63fb-2eab-4564-beab-bbceff59d25b
CloudRepositoryId : 68d691b8-077a-4eaa-ab7a-aace24c4bf60
IsAvailable : True
IsWanAcceleratorEnabled : False
Id : cf030942-4f66-4993-953d-6da2cc3655f1
Name : Interactive Cloud Repository
Description : Cloud repository
CreationDate :
Type : Cloud
Group : BackupRepository
HostId : ee9388dd-0d7a-4c76-a338-fee86081005b
MountHostId : ee9388dd-0d7a-4c76-a338-fee86081005b
Path : \XXXXXXXX
FullPath : XXXXXXXX
ShareCredsId : 00000000-0000-0000-0000-000000000000
Options : <BackupRepositoryOptions><RepositoryOptions><MaxTasksCount>-1</MaxTasksCount><OneBackupFilePerVm>True</OneBackupFilePerVm></RepositoryOptions></BackupRepositoryOptions>
EndPointCryptoKeyId : 00000000-0000-0000-0000-000000000000
IsRotatedDriveRepository : False
IsDependant : False
Status : Ordinal
DeletedRetentionSchedule : Start time: [28/11/2019 11:51:19 PM], Latest run time: [28/11/2019 11:41:19 PM], Timeout
for backup completion: [180min], Next run time: [], Retry times on failure: [3], Retry
timeout: [10 min], Daily options: [Enabled: True, DayNumberInMonth: Everyday, Days: Monday,
Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday]
CachedTotalSpace : -1
CachedFreeSpace : -1
VersionOfCreation : 9.5.4.2753
UseNfsOnMountHost : False
IsReadOnly : False
Hello, iam stuck in the connection. Changed localhost to our server:
param( [Parameter(Position=0, Mandatory=$false)] [string] $BRHost = "BKUP01",
With PSx64.exe i get the wanted XML output. But the Sensor Logs comes up with:
Failed to connect to Veeam BR Host
even when it is hardcoded in the powershell script. So i checked the user, its running with a credential which is approved to connect. Means i logged in on the same remote host the PRTG probe is installed and run the script with PSx64 which gives me the XML output.
Error Output: `C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\VeeamBRStats.ps1 : Failed to connect to Veeam BR Host At line:1 char:1
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExcep
tion
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio
n,VeeamBRStats.ps1
`
` OS: WS 2016 PSx64: 18.1.1.6
0: Name Value
PSVersion 5.1.14393.3053 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.14393.3053 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1`
Also i tried with Parameters in PRTG as:
-f="FileName.ps1 -p="BKUP01"
and -f="FileName.ps1" -p="-BRHost BKUP01"
Any ideas here?
Okay, space info is missing for CC Repositories.
Let's try the "UpdateSpaceInfo" method:
[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, @{Name="CachedTotalSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedTotalSpace/1GB,2)}}, @{Name="CachedFreeSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedFreeSpace/1GB,2)}} | Format-Table -AutoSize
## Try UpdateSpaceInfo Method and oupot original Object
$CCrepo = $RepoList | Where { $_.Name -match "Interactive Cloud Repository"}
$CCrepo.UpdateSpaceInfo
$CCrepo.info | Select *
## Second Query
[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 | Where { $_.Name -match "Interactive Cloud Repository"}).info | Select *
PS C:\Scripts> [Array]$RepoList = Get-VBRBackupRepository | Where-Object {$_.Type -ne "SanSnapshotOnly"}
PS C:\Scripts> [Array]$ScaleOuts = Get-VBRBackupRepository -ScaleOut
PS C:\Scripts> if ($ScaleOuts) {
>> foreach ($ScaleOut in $ScaleOuts) {
>> $Extents = Get-VBRRepositoryExtent -Repository $ScaleOut
>> foreach ($Extent in $Extents) {
>> $RepoList = $RepoList + $Extent.repository
>> }
>> }
>> }
>> $RepoList | Select-Object Name, @{Name="CachedTotalSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedTotalS
pace/1GB,2)}}, @{Name="CachedFreeSpaceGB"; Expression= {[Math]::Round([Decimal]$_.info.CachedFreeSpace/1GB,2)}} | Format
-Table -AutoSize
>>
Name CachedTotalSpaceGB CachedFreeSpaceGB
---- ------------------ -----------------
Interactive Cloud Repository 0.00 0.00
Backup Repository (Configuration) 40.00 24.04
Backup Repository 1 (REP01) 8373.5 3223.33
Backup Repository (MA1_2) 50287.12 22503.02
PS C:\Scripts> ## Try UpdateSpaceInfo Method and oupot original Object
PS C:\Scripts> $CCrepo = $RepoList | Where { $_.Name -match "Interactive Cloud Repository"}
PS C:\Scripts> $CCrepo.UpdateSpaceInfo
OverloadDefinitions
-------------------
void UpdateSpaceInfo(long totalSpace, long freeSpace)
void IBackupRepository.UpdateSpaceInfo(long totalSpace, long freeSpace)
PS C:\Scripts> $CCrepo.info | Select *
ProviderId : a43d63fb-2eab-4564-beab-bbceff59d25b
CloudRepositoryId : 68d691b8-077a-4eaa-ab7a-aace24c4bf60
IsAvailable : True
IsWanAcceleratorEnabled : False
Id : cf030942-4f66-4993-953d-6da2cc3655f1
Name : Interactive Cloud Repository
Description : Cloud repository
CreationDate :
Type : Cloud
Group : BackupRepository
HostId : ee9388dd-0d7a-4c76-a338-fee86081005b
MountHostId : ee9388dd-0d7a-4c76-a338-fee86081005b
Path : \XXXXXXXX
FullPath : XXXXXXXX
ShareCredsId : 00000000-0000-0000-0000-000000000000
Options : <BackupRepositoryOptions><RepositoryOptions><MaxTasksCount>-1</MaxTasksCount><OneBackupFileP
erVm>True</OneBackupFilePerVm></RepositoryOptions></BackupRepositoryOptions>
EndPointCryptoKeyId : 00000000-0000-0000-0000-000000000000
IsRotatedDriveRepository : False
IsDependant : False
Status : Ordinal
DeletedRetentionSchedule : Start time: [4/12/2019 1:35:33 PM], Latest run time: [4/12/2019 1:25:33 PM], Timeout for
backup completion: [180min], Next run time: [], Retry times on failure: [3], Retry timeout:
[10 min], Daily options: [Enabled: True, DayNumberInMonth: Everyday, Days: Monday, Tuesday,
Wednesday, Thursday, Friday, Saturday, Sunday]
CachedTotalSpace : -1
CachedFreeSpace : -1
VersionOfCreation : 9.5.4.2753
UseNfsOnMountHost : False
IsReadOnly : False
PS C:\Scripts> ## Second Query
PS C:\Scripts> [Array]$RepoList = Get-VBRBackupRepository | Where-Object {$_.Type -ne "SanSnapshotOnly"}
PS C:\Scripts> [Array]$ScaleOuts = Get-VBRBackupRepository -ScaleOut
PS C:\Scripts> if ($ScaleOuts) {
>> foreach ($ScaleOut in $ScaleOuts) {
>> $Extents = Get-VBRRepositoryExtent -Repository $ScaleOut
>> foreach ($Extent in $Extents) {
>> $RepoList = $RepoList + $Extent.repository
>> }
>> }
>> }
>> ($RepoList | Where { $_.Name -match "Interactive Cloud Repository"}).info | Select *
>>
ProviderId : a43d63fb-2eab-4564-beab-bbceff59d25b
CloudRepositoryId : 68d691b8-077a-4eaa-ab7a-aace24c4bf60
IsAvailable : True
IsWanAcceleratorEnabled : False
Id : cf030942-4f66-4993-953d-6da2cc3655f1
Name : Interactive Cloud Repository
Description : Cloud repository
CreationDate :
Type : Cloud
Group : BackupRepository
HostId : ee9388dd-0d7a-4c76-a338-fee86081005b
MountHostId : ee9388dd-0d7a-4c76-a338-fee86081005b
Path : \XXXXXXXX
FullPath : XXXXXXXX
ShareCredsId : 00000000-0000-0000-0000-000000000000
Options : <BackupRepositoryOptions><RepositoryOptions><MaxTasksCount>-1</MaxTasksCount><OneBackupFileP
erVm>True</OneBackupFilePerVm></RepositoryOptions></BackupRepositoryOptions>
EndPointCryptoKeyId : 00000000-0000-0000-0000-000000000000
IsRotatedDriveRepository : False
IsDependant : False
Status : Ordinal
DeletedRetentionSchedule : Start time: [4/12/2019 1:35:34 PM], Latest run time: [4/12/2019 1:25:34 PM], Timeout for
backup completion: [180min], Next run time: [], Retry times on failure: [3], Retry timeout:
[10 min], Daily options: [Enabled: True, DayNumberInMonth: Everyday, Days: Monday, Tuesday,
Wednesday, Thursday, Friday, Saturday, Sunday]
CachedTotalSpace : -1
CachedFreeSpace : -1
VersionOfCreation : 9.5.4.2753
UseNfsOnMountHost : False
IsReadOnly : False
Hi, the connected Cloud Repositories need to be handled completely different. One of the Veeam folks gave me this hint in the Forum:
# Gathering Service Providers
$providers = Get-VBRCloudProvider
# Gathering Cloud Repositories
$repos = Get-VBRBackupRepository | Where-Object {$_.Type -eq "Cloud"}
foreach ($provider in $providers){
# Only process provider if backup resources have been allocated
if ($provider.Resources){
# In case multiple resources have been assigned
foreach ($resource in $provider.Resources){
$repo = $repos | Where-Object {($_.CloudProvider.HostName -eq $provider.DNSName) -and ($_.Name -eq $resource.RepositoryName)}
$totalSpaceGb = [Math]::Round([Decimal]$resource.RepositoryAllocatedSpace/1KB,2)
$totalUsedGb = [Math]::Round([Decimal]([Veeam.Backup.Core.CBackupRepository]::GetRepositoryStoragesSize($repo.Id.Guid))/1GB,2)
Write-Output "Service Provider: $($provider.DNSName)"
Write-Output "Repository Name: $($resource.RepositoryName)"
Write-Output "Total Space GB: $totalSpaceGb"
Write-Output "Totale Used GB: $totalUsedGb"
}
}
}
If this works, I should be able to include that into the PRTG Script.
That appears to have worked!
Service Provider: XXXXX.XXXXXXXXXX.XXX
Repository Name: Interactive Cloud Repository
Total Space GB: 15500
Totale Used GB: 5484.43
Hi, I have tried to combine the Code Snippet you have already verified with the existing Script. As before I was not able to verify the Cloud Repo Part.
So, might you please test the new version: https://github.com/mycloudrevolution/Advanced-PRTG-Sensors/blob/IncludeCloudRepos/Veeam/PRTG-VeeamBRStats.ps1
.\PRTG-VeeamBRStats-NEW.ps1 -Debug
If it works, a measurement of the execution might be interesting (Please execute both versions multiple times before measurement or restart PS Session between the tests):
PS C:\temp> (Measure-Command {.\PRTG-VeeamBRStats.ps1}).Milliseconds
462
PS C:\temp> (Measure-Command {.\PRTG-VeeamBRStats-NEW.ps1}).Milliseconds
532
Output as requested below. Measurement tests were completed after multiple runs of both scripts as suggested.
A couple of cosmetic things I noticed "Failes-Backups" - typo? "DEBUG: Total Free GB: 36" - Should this be percent?
PS C:\Scripts> .\PRTG-VeeamBRStats-NEW.ps1 -debug -BRhost bneveeam01
DEBUG: Starting to Process Connection to bneveeam01 ...
DEBUG: Connecting BRHost...
<prtg>
<result>
<channel>Successful-Backups</channel>
<value>2</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Warning-Backups</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxWarning>0</LimitMaxWarning>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failes-Backups</channel>
<value>1</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failed-Backups</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Running-Backups</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>TotalBackupRead</channel>
<value>408</value>
<unit>Custom</unit>
<customUnit>GB</customUnit>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>TotalBackupTransfer</channel>
<value>133</value>
<unit>Custom</unit>
<customUnit>GB</customUnit>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Successful-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Warning-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxWarning>0</LimitMaxWarning>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failes-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failed-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Running-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Idle-BackupCopys</channel>
<value>1</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Successful-Replications</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Warning-Replications</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxWarning>0</LimitMaxWarning>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failes-Replications</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failed-Replications</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Running-Replications</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Successful-Endpoints</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Warning-Endpoints</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxWarning>0</LimitMaxWarning>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failes-Endpoints</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Running-Endpoints</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
DEBUG: Veeam.Backup.Model.CBackupRepositoryInfo
DEBUG: Veeam.Backup.Model.CBackupRepositoryInfo
DEBUG: Veeam.Backup.Model.CBackupRepositoryInfo
DEBUG: Cloud Repo Section Entered...
DEBUG: Repository Name: Interactive Cloud Repository
DEBUG: Total Space GB: 15500
DEBUG: Total Used GB: 9912.95
DEBUG: Total Free GB: 5587.05
DEBUG: Total Free GB: 36
<result>
<channel>REPO - Backup Repository (Configuration)</channel>
<value>60</value>
<unit>Percent</unit>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMinWarning>20</LimitMinWarning>
<LimitMinError>10</LimitMinError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>REPO - Backup Repository 1 (REP01)</channel>
<value>37</value>
<unit>Percent</unit>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMinWarning>20</LimitMinWarning>
<LimitMinError>10</LimitMinError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>REPO - Backup Repository (MA1_2)</channel>
<value>44</value>
<unit>Percent</unit>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMinWarning>20</LimitMinWarning>
<LimitMinError>10</LimitMinError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>REPO - </channel>
<value>36</value>
<unit>Percent</unit>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMinWarning>20</LimitMinWarning>
<LimitMinError>10</LimitMinError>
<LimitMode>1</LimitMode>
</result>
</prtg>
Repository Name Free (GB) Total (GB) Free (%) Status
--------------- --------- ---------- -------- ------
Backup Repository (Configuration) 24.17 40.00 60 OK
Backup Repository 1 (REP01) 3110.33 8373.5 37 OK
Backup Repository (MA1_2) 22088.35 50287.12 44 OK
5587.05 15500 36 OK
Successful Backups : 2
Warning Backups : 0
Failes Backups : 1
Failed Backups : 0
Running Backups : 0
Total Backup Transfer : 133
Total Backup Read : 408
Warning BackupCopys : 0
Failes BackupCopys : 0
Failed BackupCopys : 0
Running BackupCopys : 0
Idle BackupCopys : 1
Successful Replications : 0
Warning Replications : 0
Failes Replications : 0
Failed Replications : 0
Running Replications : 0
Seccessful Endpoints : 0
Warning Endpoints : 0
Failes Endpoints : 0
Running Endpoints : 0
PS C:\Scripts> (Measure-Command {.\PRTG-VeeamBRStats.ps1 -BRHost bneveeam01}).Milliseconds
51
PS C:\Scripts> (Measure-Command {.\PRTG-VeeamBRStats-NEW.ps1 -BRHost bneveeam01}).Milliseconds
434
Is that what you are looking for (the missing cloud Repo name is just a typo) ?
If you have any more patience, we can try to reduce the growth of execution time.
Yes that looks like its picking up the repo properly. Statistics look correct.
Happy to assist you further with testing if you want to optimise the code.
Hi, I have fixed the Cloud Repo Name and tried to speed up the Script a little bit (more tweaks in the making).
Might please Verify this Version_ https://github.com/mycloudrevolution/Advanced-PRTG-Sensors/blob/IncludeCloudRepos/Veeam/PRTG-VeeamBRStats.ps1
.\PRTG-VeeamBRStats-NEW.ps1 -Debug
(Measure-Command {.\PRTG-VeeamBRStats-NEW.ps1}).Milliseconds
I assume that the Cloud Repo process takes pretty long. Might you please also run this snippet to get that verified:
(Measure-Command {
# Gathering Service Providers
$providers = Get-VBRCloudProvider
# Gathering Cloud Repositories
$repos = Get-VBRBackupRepository | Where-Object {$_.Type -eq "Cloud"}
foreach ($provider in $providers){
# Only process provider if backup resources have been allocated
if ($provider.Resources){
# In case multiple resources have been assigned
foreach ($resource in $provider.Resources){
$repo = $repos | Where-Object {($_.CloudProvider.HostName -eq $provider.DNSName) -and ($_.Name -eq $resource.RepositoryName)}
$totalSpaceGb = [Math]::Round([Decimal]$resource.RepositoryAllocatedSpace/1KB,2)
$totalUsedGb = [Math]::Round([Decimal]([Veeam.Backup.Core.CBackupRepository]::GetRepositoryStoragesSize($repo.Id.Guid))/1GB,2)
Write-Output "Service Provider: $($provider.DNSName)"
Write-Output "Repository Name: $($resource.RepositoryName)"
Write-Output "Total Space GB: $totalSpaceGb"
Write-Output "Totale Used GB: $totalUsedGb"
}
}
}
}).Milliseconds
Hi. I am having an issue where when I run the script using PSx64.exe I receive the following:
Running the script manually in an x64 PowerShell window results in the correct output being displayed.
Can anyone suggest what I am doing wrong?