I have a simple script, which I want to show me some results, but in the name of the virtual machine, I only want to the first point, everything else is left over because it generates a lot of noise.
$today = (get-date).Date
$backup = Get-VBRBackup | where {$_.info.jobname -eq "A. ProduccionInterna.Infraestructura Backup Copy"}
if ($backup) {
$backup.GetAllStorages() | where {$_.CreationTime.Date -eq $today} | select @{Name="Nombre de la VM"; Expression={$_.PartialPath[0]}}, @{Name="Size VM"; Expression={$_.Stats.BackupSize/1GB}} , @{Name="Deduplicacion"; Expression={$Session.BackupStats.DedupRatio/10}} , @{Name="Compress Ratio"; Expression={$Session.BackupStats.CompressRatio/10}} , @{Name="Fecha"; Expression={(get-date).Date}}
}
Result:
f5downinxn.vm-37087D2020-02-21T030000_B816.vib
But, I wont:
f5downinxn
The chain that entered does not seem to work.
[0]
I have also tried with
(".")[1]
EDIT
With my code:
Nombre de la VM : f5downinxn.vm-37087D2020-02-21T030000_B816.vib
With changes:
Code
$today = (get-date).Date
$backup = Get-VBRBackup | where {$_.info.jobname -eq "A. ProduccionInterna.Infraestructura Backup Copy"}
if ($backup) {
$backup.GetAllStorages() | where {$_.CreationTime.Date -eq $today} | select @{Name="Nombre de la VM"; Expression={$_.PartialPath[0].split('.')[0]}}, @{Name="Size VM"; Expression={$_.Stats.BackupSize/1GB}} , @{Name="Deduplicacion"; Expression={$Session.BackupStats.DedupRatio/10}} , @{Name="Compress Ratio"; Expression={$Session.BackupStats.CompressRatio/10}} , @{Name="Fecha"; Expression={(get-date).Date}}
}
Nombre de la VM :
The .PartialPath
property is a Veeam.Backup.Common.CPartialPath
object. The tabular output is performing some string conversion magic, but the underlying object is not a string. However, Veeam.Backup.Common.CPartialPath
has a ToString()
override method that should make this task easier.
Select @{Name="Nombre de la VM"; Expression={$_.PartialPath.ToString().Split('.')[0]}}