PowerShell script exchange
Post Reply
Markol
Enthusiast
Posts: 26
Liked: 2 times
Joined: Apr 20, 2012 12:12 pm
Full Name: Marko Lehto
Contact:

With PS get latsetresult

Post by Markol » Nov 28, 2014 9:05 am

Hi all,

I'm trying to get this to work for me.

Thinking like this..

Code: Select all

$sendmail =$False
(get-vbrjob -name backupjob_name).GetLastResult()

if ($GetLastResult -eq $Fail )
{
$Sendmail=$True
}

if ($sendmail -eq $True {

My email function

}

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

Re: With PS get latsetresult

Post by veremin » Nov 28, 2014 9:08 am

It seems that you need something like this, right? Thanks.

Markol
Enthusiast
Posts: 26
Liked: 2 times
Joined: Apr 20, 2012 12:12 pm
Full Name: Marko Lehto
Contact:

Re: With PS get latsetresult

Post by Markol » Nov 28, 2014 9:20 am

v.Eremin wrote:It seems that you need something like this, right? Thanks.

aa thanks alot v.Eremin. hmm then I was not that faraway of solving it my self... haha just a few rows =)

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

Re: With PS get latsetresult

Post by veremin » Nov 28, 2014 9:24 am

Yep, the missing part was assigning either job or its result to a variable. Thanks.

Markol
Enthusiast
Posts: 26
Liked: 2 times
Joined: Apr 20, 2012 12:12 pm
Full Name: Marko Lehto
Contact:

Re: With PS get latsetresult

Post by Markol » Dec 09, 2014 1:30 pm

Sorry, but I need to wake up this post again..

How can I get the lastresult into a variable?

Code: Select all

$Job = Get-VBRJob -name "Name of your job"
If ($job.GetLastresult() -eq "Warning" -or $job.GetLastresult() -eq "Success")
{
write-host "The backup $job did not go so well, it ended up in (???$job.GetLastresult())
}

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

Re: With PS get latsetresult

Post by veremin » Dec 09, 2014 8:09 pm

The script referenced by you should work as expected. My point was that you had to assign either Job or its result to a variable and then make a comparison ("if" portion). Thanks.

Markol
Enthusiast
Posts: 26
Liked: 2 times
Joined: Apr 20, 2012 12:12 pm
Full Name: Marko Lehto
Contact:

Re: With PS get latsetresult

Post by Markol » Dec 10, 2014 11:39 am 1 person likes this post

aa now the coin fell down =)

Thanks a lot v.Eremin

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

Re: With PS get latsetresult

Post by veremin » Dec 10, 2014 5:36 pm

No problem. Feel free to reach us, should other help be needed. Thanks.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest