I am trying to find all last job statuses fro a list of VMs backed up with veeam backup. Strangely the loop do not go to the next vm. Here is what I do:
Add-PSSnapin VeeamPSSnapin
$VMlist = "vm1, vm2"
$VMlist = $VMlist.split(",");
Foreach ($i in $VMlist) {
foreach($Job in (Get-VBRJob))
{
$Session = $Job.FindLastSession()
if(!$Session){continue;}
$Tasks = $Session.GetTaskSessions()
$Tasks | ?{$_.Name -eq $VMlist} | %{write-host $_.Name ":" $_.Status}
It seems I have a problem in the for each loop, since it stuck and I do not get any output. What is thebest way to iterate over the slit of VMs?
Thanks in advance!