PowerShell script exchange
Markol
Enthusiast
Posts: 26 Liked: 2 times
Joined: Apr 20, 2012 12:12 pm
Full Name: Marko Lehto
Contact:
Post
by Markol » Nov 28, 2014 9:05 am
this post
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:
Post
by veremin » Nov 28, 2014 9:08 am
this post
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:
Post
by Markol » Nov 28, 2014 9:20 am
this post
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:
Post
by veremin » Nov 28, 2014 9:24 am
this post
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:
Post
by Markol » Dec 09, 2014 1:30 pm
this post
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:
Post
by veremin » Dec 09, 2014 8:09 pm
this post
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:
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: 20400 Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Dec 10, 2014 5:36 pm
this post
No problem. Feel free to reach us, should other help be needed. Thanks.