Is there an easy script that someone already has created ?
powershell commands to list out all clients not backed for last N days in otherwise clients that have failed for last N days.
-
- Lurker
- Posts: 2
- Liked: never
- Joined: Jun 03, 2020 2:18 pm
- Full Name: Bharath Kumar CM
- Contact:
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: powershell commands to list out all clients not backed for last N days
Hi Bharath,
In terms of failed backups what you are looking for is task sessions status for each job run. Example:
Thanks,
Oleg
In terms of failed backups what you are looking for is task sessions status for each job run. Example:
Code: Select all
$sessions = @()
$objects = @()
$date = Get-Date
$jobs = Get-VBRJob
foreach ($job in $jobs) {
$object = Get-VBRJobObject -Job $job
$sessionName = $job.Name + '*'
$session = Get-VBRBackupSession -Name $sessionName | where {$_.EndTimeUTC -ge $date.AddDays(-2)}
$sessions += $session
$objects += $name
}
foreach ($session in $sessions) {
foreach ($object in $objects) {
Get-VBRTaskSession -Session $session -Name $object.Name | where {$_.Status -eq 'Failed'}
}
}
Oleg
-
- Lurker
- Posts: 2
- Liked: never
- Joined: Jun 03, 2020 2:18 pm
- Full Name: Bharath Kumar CM
- Contact:
Re: powershell commands to list out all clients not backed for last N days
Oleg,
I don't see any output when i execute these commands.
PS C:\Users\ad_acharbha> Add-PSSnapin VeeamPSSnapin
PS C:\Users\ad_acharbha> C:\Users\ad_acharbha\Desktop\test.ps1
content is your code
I don't see any output when i execute these commands.
PS C:\Users\ad_acharbha> Add-PSSnapin VeeamPSSnapin
PS C:\Users\ad_acharbha> C:\Users\ad_acharbha\Desktop\test.ps1
content is your code
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: powershell commands to list out all clients not backed for last N days
My example shows only those backups failed for the last 2 days. Are you sure you have any? Try changing AddDays(-2) value to something else.
I also figured that most of the code I shared is redundant. This should do:
Thanks!
I also figured that most of the code I shared is redundant. This should do:
Code: Select all
$date = Get-Date
$sessions = Get-VBRBackupSession | where {$_.EndTimeUTC -ge $date.AddDays(-2)}
foreach ($session in $sessions) {
Get-VBRTaskSession -Session $session -Name $object.Name | where {$_.Status -eq 'Failed'}
}
Who is online
Users browsing this forum: No registered users and 5 guests