veeam backup powershell
veeam backup powershell
REGISTER LOGIN
4. How can I check the status (success/failure) of VM and physical machine full backup
jobs?
1. Get all backup job sessions ran for the last 24 hours. Datetime class has another
method for that. Since you already use AddDays(), I guess you can easily figure out how
it's called for hours.
Thanks,
Oleg
Thanks to you, I made a PowerShell to check the backup status of the physical server.
But, in the
$_.CreationTime -gt (Get-Date).AddDays(-1)
part, the result value one day before I want is not displayed, but the contents of the entire
date are displayed.
OutPut:
JobName JobType CreationTime EndTime Result State BackupSize
------- ------- ------------ ------- ------ ----- ----------
VM_Job Backup 3/21/2021 8:17:49 AM 3/21/2021 8:41:59 AM Warning Stopped 18063425536
the result value one day before I want is not displayed, but the contents of the entire date
are displayed.
Try using AddHours() method on Get-Date, looks like it fits more in your case.
Thanks,
Oleg
I've tried running 2 powershells to check the status of backup jobs that have been running
for 24 hours from the current time.
$date = (Get-Date).AddHours(-24)
$sessions = Get-VBRComputerBackupJobSession
$sessions | where {$_.CreationTime -ge $date} | sort CreationTime | Format-Table
Thanks,
Oleg
Thanks,
Oleg
Thanks to your help, I created the final PowerShell script like the one below.
$date = (Get-Date).AddHours(-24)
$sessions = Get-VBRComputerBackupJobSession
foreach ($PBackup_job in (Get-VBRComputerBackupJob | Select Name)) {
$PBackup_job_name = $PBackup_job.Name
write "------------ Physical Server Backup Job Name : $PBackup_job_name ------------"
$sessions | where {$_.CreationTime -ge $date} | sort CreationTime | Select CreationTime, endti
}
Re: Question - Backup Job check powershell jbyoon
Novice
for Last 24 hours
by jbyoon » Mar 23, 2021 10:26 am Posts: 6
Liked: never
Joined: Feb 06, 2020 12:07 pm
I created a PowerShell that outputs the status of two types of backup jobs(VM and physical Full Name: YOON JOO BYOUNG
server) within 24 hours. Contact:
Thanks to everyone who helped.
Add-PSSnapin Veeampssnapin
$date = (Get-Date).AddHours(-24)
$VMsessions = Get-VBRBackupSession
$VMsessions | where {$_.CreationTime -ge $date} |Select @{Name="Type";Expression={"VM"}},@{Name="JobN
$PMsessions = Get-VBRComputerBackupJobSession
foreach ($PBackup_job in (Get-VBRComputerBackupJob | Select Name)) {
$PBackup_job_name = $PBackup_job.Name
$PMsessions | where {$_.CreationTime -ge $date} | sort CreationTime | Select @{Name="Type";Exp
}
Re: Question - Backup Job check powershell Rajesh1210
Influencer
for Last 24 hours
Posts: 12
by Rajesh1210 » Apr 20, 2022 1:41 pm
Liked: never
Joined: Feb 22, 2021 3:31 pm
Hi Oleg, Full Name: Rajesh TK
Contact:
How to list the session for a specific creation time. I am trying the below, but it is not
working.
$date = (Get-Date).AddHours(-24)
$sessions = Get-VBRComputerBackupJobSession
$sessions | where {$_.CreationTime -ge $date} | sort CreationTime | Format-Table
Thanks,
Oleg
Re: Question - Backup Job check powershell rennerstefan
Veeam Software
for Last 24 hours
Posts: 680
by rennerstefan » Apr 20, 2022 2:00 pm
Liked: 149 times
Joined: Jan 22, 2015 2:39 pm
One way would be: Full Name: Stefan Renner
Location: Germany
Contact:
CODE: SELECT ALL
$sessions | where {$_.CreationTime.day -eq "20" -and $_.CreationTime.month -eq "4" -and $_.CreationTi
Stefan Renner
Veeam PMA
It is not working because you are trying to filter CreationTime of datetime type by a string
value. There is no type conversion happenning in this case. Adding to the way Stefan
mentioned, another one would be to parse a date from a string and then use it for
filtering:
$date = [Datetime]::Parse('4/16/2022')
$sessions | where {$_.CreationTime.Date -eq $date}
In this case make sure to filter by CreationTime.Date, not just CreationTime. Otherwise
hours/minutes/seconds in $date won't be ignored, and you will likely receive no results
unless some sessions were started precisely at a default time written to $date (12:00:00
AM).
Thanks,
Oleg
I used the above suggestion but it did not filter out anything. Here is my code,
Not sure what is missing. Could you please help with this?
Do you mean that it didn't reflect anything or it reflected many more irrelevant sessions?
If it's the first scenario, it would likely mean that it is either something wrong on the steps
of getting job and sessions or no session ran on that date. In this case I'd advise to check
if $job and $session variables hold any values. If they do, please double check if any
session ran on that day for the mentioned job.
Thanks,
Oleg
Rajesh1210
Re: Question - Backup Job check powershell Influencer
for Last 24 hours
Posts: 12
by Rajesh1210 » Apr 26, 2022 12:05 pm Liked: never
Joined: Feb 22, 2021 3:31 pm
Hi Oleg, Full Name: Rajesh TK
Contact:
$job and $session had values in it but not for the date I was querying for. I re-ran them to
populate again. I am able to get what I looked for. Thanks a lot for the help!
16 posts • Page 1 of 1
POST REPLY
Return to “PowerShell”
WHO IS ONLINE
Users browsing this forum: No registered users and 9 guests
MAIN CONTACT US THE TEAM MEMBERS DELETE COOKIES ALL TIMES ARE UTC
DISCLAIMER: All feature and release plans are subject to change without notice.