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 »

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

Re: With PS get latsetresult

Post by veremin »

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 »

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

Re: With PS get latsetresult

Post by veremin »

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 »

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

Re: With PS get latsetresult

Post by veremin »

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 » 1 person likes this post

aa now the coin fell down =)

Thanks a lot v.Eremin
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: With PS get latsetresult

Post by veremin »

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

Who is online

Users browsing this forum: flaviano.teodoro and 15 guests