add GB and TB

Welcome Forums General PowerShell Q&A add GB and TB

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
3 months ago.

  • Author
    Posts
  • #108554

    Inactive
    Points: 0
    Rank: Member

    Hi guys please help me can any body make this on GB and TB please thanks.
    $backups = get-vbrbackup
    $allstorages = @()
    foreach ($backup in $backups) {
    foreach ($storage in $backup.getallstorages()) {
    $allstorages += New-Object -TypeName psobject -Property @{
    JobName=$backup.Name;
    Time=$storage.CreationTime;
    Path=$storage.Info.FilePath;
    BackupSizeGB=$storage.Info.Stats.BackupSize/1GB;
    DataSizeGB=$storage.Info.Stats.DataSize/1GB;
    }
    }
    }
    $allstorages = $allstorages | Sort-Object -Property JobName,Time
    $allstorages | select -property Jobname,Time,Path,BackupSizeGB,DataSizeGB | Format-Table -AutoSize

  • #108559

    Participant
    Points: 206
    Helping Hand
    Rank: Participant

    I may not be clear on what you are after, but I am going to assume you mean turning this...

    BackupSizeGB=$storage.Info.Stats.BackupSize/1GB;
    DataSizeGB=$storage.Info.Stats.DataSize/1GB;

    … into this...

    BackupSizeGB=$storage.Info.Stats.BackupSize/1TB;
    DataSizeGB=$storage.Info.Stats.DataSize/1TB;
    

    The math approach is the same, but use and if/then to determine when the GB size hits the TB threshold.  For example...

    if(DataSizeGB -ge 1024){DataSizeGB=$storage.Info.Stats.DataSize/1TB}
    if(BackupSizeGB -ge 1024){BackupSizeGB=$storage.Info.Stats.BackupSize/1TB}
    

    … or have two columns, on in GB and the other in TB.

    See this article:

    'powershellmagazine.com/2013/05/20/converting-to-size-units-kb-mbgbtb-and-pb-without-using-powershell-multipliers'

You must be logged in to reply to this topic.