thanks for all the quick replies. Working with another guy here, we got it working, well, most of it. Still having a problem with a non-veeam aspect of the function we're trying to create. To address one of the replies, yes, we are trying to
restore multiple dates on the same VM. Once its up, we take a look at a specific directory, do some fun counting stuff, write that to a csv and then stop the
restore. The loop is to go back and do it again with a different date. Once its gone through the list of dates, we can examine the CSV, and find which
restore date has the directory in the state we want it to be. I'll include what I can of the script below.
Thanks again for the assist.
Code: Select all
asnp "VeeamPSSnapIn" -ErrorAction SilentlyContinue
## Declare
$job = "<jobname>"
$vm = "vmname"
$path = "c:\veeamflr\"
$dir = "<second half of path>"
$finalpath = $path+$vm+$dir
$countcsv = "C:\util\scripts\count.csv"
$creationcsv = "C:\util\scripts\creationtimestring.csv"
##Generate List of Dates to examine. This is separate, in case we want to remove entries from the CSV.
##Could/should be separate script all together, but there may be a case for it to be together as well
$gen = Get-VBRBackup -Name $job | get-vbrrestorepoint -name "$vm"
$gen.creationtimestring >> $creationcsv
#import date, start the loop
import-csv $creationcsv -header date | foreach-object{
$dateofres=$_.date
#Start the Restore
write-host "Attempting to restore" $dateofres
$res = Get-VBRBackup | where {$_.JobName -eq "$job"} | Get-VBRRestorePoint | sort CreationTime -Descending | where {$_.VMName -eq "$vm"} | select -First 1 | Start-VBRWindowsFileRestore
#count the files - Where we still have problems
$files = (get-childitem $finalpath -recurse).count
#put the count, the vm name and backup creation date in a csv
$files, $res.name, $res.CreationTimeString >> $countcsv
#stop the file restore
stop-vbrwindowsfilerestore $vm
}