PowerShell script exchange
jmertensnetuk
Service Provider
Posts: 46 Liked: 13 times
Joined: Sep 14, 2017 2:58 pm
Full Name: Jonathan Mertens
Contact:
Post
by jmertensnetuk » Aug 14, 2019 9:57 am
this post
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:
Post
by veremin » Aug 14, 2019 11:39 am
this post
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:
Post
by jmertensnetuk » Aug 15, 2019 9:59 am
this post
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:
Post
by veremin » Aug 15, 2019 3:15 pm
this post
Out-File cmdlet will help you with that. Thanks!
Users browsing this forum: No registered users and 12 guests