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

Script not returning all VM in backups

Post by jmertensnetuk »

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: 20402
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Script not returning all VM in backups

Post by veremin »

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: 46
Liked: 13 times
Joined: Sep 14, 2017 2:58 pm
Full Name: Jonathan Mertens
Contact:

Re: Script not returning all VM in backups

Post by jmertensnetuk »

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: 20402
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Script not returning all VM in backups

Post by veremin »

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

Who is online

Users browsing this forum: No registered users and 12 guests