PowerShell script exchange
Post Reply
jmertensnetuk
Service Provider
Posts: 42
Liked: 12 times
Joined: Sep 14, 2017 2:58 pm
Full Name: Jonathan Mertens
Contact:

Script not returning all VM in backups

Post by jmertensnetuk » Aug 14, 2019 9:57 am

Hi All,

Below returns some information I want, my aim is to search all backup (primary main backup jobs of which there are 6) and print out the VMName and latest creationtime.

However when I run the below script it only returns back about half the VM's that are in the backup files it is skipping some jobs completly and therefore the VM's inside those jobs.

Code: Select all

Add-PSSnapin VeeamPSSnapin
$jobs = Get-VBRBackup | where {$_.JobType -eq "Backup"}

ForEach ($job in $jobs) {
Get-VBRRestorePoint -Backup $job | Sort-Object –Property CreationTime –Descending | Select VMName, CreationTime -First 1
}
I am new to this so I have probably done something obvious wrong

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Script not returning all VM in backups

Post by veremin » Aug 14, 2019 11:39 am

Try this example:

Code: Select all

Add-PSSnapin VeeamPSSnapin
$VMs = Get-VBRJob | where {$_.JobType -eq "Backup"} | Get-VBRJobObject
Foreach ($VM in $VMs)
{
    Get-VBRRestorePoint -ObjectId $VM.ObjectId | sort creationtime -Descending | Select -First 1 | Select VMName, CreationTime
}
Thanks!

jmertensnetuk
Service Provider
Posts: 42
Liked: 12 times
Joined: Sep 14, 2017 2:58 pm
Full Name: Jonathan Mertens
Contact:

Re: Script not returning all VM in backups

Post by jmertensnetuk » Aug 15, 2019 9:59 am

Hello veremin,

Perfect this seems to do it.

If i wanted to output this to a .txt file for example what would be required?

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Script not returning all VM in backups

Post by veremin » Aug 15, 2019 3:15 pm

Out-File cmdlet will help you with that. Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests