PowerShell script exchange
Post Reply
Frank_190
Influencer
Posts: 20
Liked: 4 times
Joined: Feb 21, 2017 9:47 pm
Full Name: Frank Pisano
Contact:

Getting Server Backup Start and End Times

Post by Frank_190 »

I am running the Powershell report that Shawn Masterson created back in the day. Veeam v9 - My Veeam Report 9.5.3 - Shawn Masterson's Blog (smasterson.com).
I am wondering if I could get some assistance in figuring out why I am not able to get the start and end times from the backup task. Here is the code block that I think is responsible for this section.
The start and end time columns are not populating with any data.
Can someone please assist me in figuring this out?

Code: Select all

$taskListBk = @()
$taskListBk += $sessListBk | Get-VBRTaskSession
$successTasksBk = @($taskListBk | ?{$_.Status -eq "Success"})
$wfTasksBk = @($taskListBk | ?{$_.Status -match "Warning|Failed"})
$runningTasksBk = @()
$runningTasksBk += $runningSessionsBk | Get-VBRTaskSession | ?{$_.Status -match "Pending|InProgress"}
write-host $runningTasksBk

# Get all Backup Tasks
$bodyAllTasksBk = $null
If ($showAllTasksBk) {
  If ($taskListBk.count -gt 0) {
    If ($showDetailedBk) {
      $bodyAllTasksBk = $taskListBk | Select @{Name="VM Name"; Expression = {$_.Name}},
        @{Name="Job Name"; Expression = {$_.JobSess.Name}},
        @{Name="Start Time"; Expression = {$_.Progress.StartTime}},
       # @{Name="Start Time"; Expression = {"?"}},
        @{Name="Stop Time"; Expression = {If ($_.Progress.StopTime -eq "1/1/1900 12:00:00 AM"){"-"} Else {$_.Progress.StopTime}}},
        @{Name="Duration (HH:MM:SS)"; Expression = {Get-Duration -ts $_.Progress.Duration}},                    
        @{Name="Avg Speed (MB/s)"; Expression = {[Math]::Round($_.Progress.AvgSpeed/1MB,2)}},
        @{Name="Total (GB)"; Expression = {[Math]::Round($_.Progress.ProcessedSize/1GB,2)}},
        @{Name="Processed (GB)"; Expression = {[Math]::Round($_.Progress.ProcessedUsedSize/1GB,2)}},
        @{Name="Data Read (GB)"; Expression = {[Math]::Round($_.Progress.ReadSize/1GB,2)}},
        @{Name="Transferred (GB)"; Expression = {[Math]::Round($_.Progress.TransferedSize/1GB,2)}},
        @{Name="Details"; Expression = {($_.GetDetails()).Replace("<br />","$B$R$")}},
        Status | Sort "Start Time" | ConvertTo-HTML -Fragment
    
    } Else {
      $bodyAllTasksBk = $taskListBk | Select @{Name="VM Name"; Expression = {$_.Name}},
        @{Name="Job Name"; Expression = {$_.JobSess.Name}},
        @{Name="Start Time"; Expression = {$_.Progress.StartTime}},
        @{Name="Stop Time"; Expression = {If ($_.Progress.StopTime -eq "1/1/1900 12:00:00 AM"){"-"} Else {$_.Progress.StopTime}}},
        @{Name="Duration (HH:MM:SS)"; Expression = {Get-Duration -ts $_.Progress.Duration}},
        @{Name="Details"; Expression = {($_.GetDetails()).Replace("<br />","$B$R$")}},
        Status | Sort "Start Time" | ConvertTo-HTML -Fragment
      $bodyAllTasksBk = $subHead01 + "Backup Tasks" + $subHead02 + $bodyAllTasksBk

 

    }
  }
}
ronnmartin61
Veeam Software
Posts: 441
Liked: 131 times
Joined: Mar 07, 2016 3:55 pm
Full Name: Ronn Martin
Contact:

Re: Getting Server Backup Start and End Times

Post by ronnmartin61 »

It might be helpful to share your updated script. I pulled the 9.x version down from the site you referenced and had to make several modifications (more needed BTW) to get it to run however none related to backup task initialization or display -

https://www.dropbox.com/s/rcelzxmydhrva ... s.png?dl=0
Frank_190
Influencer
Posts: 20
Liked: 4 times
Joined: Feb 21, 2017 9:47 pm
Full Name: Frank Pisano
Contact:

Re: Getting Server Backup Start and End Times

Post by Frank_190 »

That is the script that is posted above that I am using.
MarkBoothmaa
Veeam Legend
Posts: 181
Liked: 49 times
Joined: Mar 22, 2017 11:10 am
Full Name: Mark Boothman
Location: Darlington, United Kingdom
Contact:

Re: Getting Server Backup Start and End Times

Post by MarkBoothmaa »

What version are you running it against?
Frank_190
Influencer
Posts: 20
Liked: 4 times
Joined: Feb 21, 2017 9:47 pm
Full Name: Frank Pisano
Contact:

Re: Getting Server Backup Start and End Times

Post by Frank_190 »

11.0.1.1261 P20220302
ronnmartin61
Veeam Software
Posts: 441
Liked: 131 times
Joined: Mar 07, 2016 3:55 pm
Full Name: Ronn Martin
Contact:

Re: Getting Server Backup Start and End Times

Post by ronnmartin61 » 1 person likes this post

@Frank_190 I went back to review some of the changes I made to the script to get it to run in my 11.0.1.1261 lab. I assume you've modified the version checking logic as it definitely fails out of the box. We migrated from a Powershell snapin to a Powershell module recently so the snapin load needs to be removed from the original script as well. There were also some repo size properties that have changed since v9 that had to be updated. If you have time please try my modified version - https://www.dropbox.com/t/D8smxuqwEXRsHdvq
Frank_190
Influencer
Posts: 20
Liked: 4 times
Joined: Feb 21, 2017 9:47 pm
Full Name: Frank Pisano
Contact:

Re: Getting Server Backup Start and End Times

Post by Frank_190 »

@ronnmartin61 Thank you for the updated code. That helped. Looks like the "$_.Progress.StartTime" in my version needs to be updated to "$_.Progress.StartTimeLocal".
ronnmartin61
Veeam Software
Posts: 441
Liked: 131 times
Joined: Mar 07, 2016 3:55 pm
Full Name: Ronn Martin
Contact:

Re: Getting Server Backup Start and End Times

Post by ronnmartin61 » 1 person likes this post

Ah interesting. Glad it helped!
albertwt
Veteran
Posts: 880
Liked: 47 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: Getting Server Backup Start and End Times

Post by albertwt » 1 person likes this post

Thank you for sharting the updated script @Ronn :-)
--
/* Veeam software enthusiast user & supporter ! */
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests