how to translate TargetHostID to the guest server name?

PowerShell script exchange

how to translate TargetHostID to the guest server name?

Veeam Logoby dannordquist » Mon Nov 10, 2014 3:35 pm

I'm using powershell to GetLastResult for veeam jobs that have failed or warning status, but the result only gives me a binary hash for the guest server. How do I get the actual name of the server, and if possible, how do I return the failure or warning message with powershell?

Anyone know how to do this?

Thank you,
Dan
dannordquist
Enthusiast
 
Posts: 27
Liked: 2 times
Joined: Thu Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby v.Eremin » Mon Nov 10, 2014 3:47 pm

Hi, Dan,

Kindly, try the following script:

Code: Select all
$Job = Get-VBRJob -name "Name of your Job"
$LastSession = $Job.FindLastSession()
$LastSession | Get-VBRTaskSession | ?{$_.status -eq "Failed"} | select name


Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby dannordquist » Mon Nov 10, 2014 5:03 pm

Excellent! That's perfect. Thank you.
dannordquist
Enthusiast
 
Posts: 27
Liked: 2 times
Joined: Thu Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby dannordquist » Mon Nov 10, 2014 5:05 pm

Any advice on how to pull the warning/error message text?
dannordquist
Enthusiast
 
Posts: 27
Liked: 2 times
Joined: Thu Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby v.Eremin » Mon Nov 10, 2014 5:09 pm

You can get text strings from the latest task session, using the following script. The error message should be there:

Code: Select all
$LastSession.Logger.GetLog().updatedrecords | sort starttime | select title


Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby dannordquist » Mon Nov 10, 2014 5:14 pm

That gives me "Job finished with warning at 11/9/2014" but it's the details of the warning I'm looking for
dannordquist
Enthusiast
 
Posts: 27
Liked: 2 times
Joined: Thu Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby v.Eremin » Mon Nov 10, 2014 5:27 pm

What about querying Task sessions, then:

Code: Select all
$TaskSession = $LastSession | Get-VBRTaskSession
$TaskSession.Logger.GetLog().updatedrecords | sort starttime | select title


Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby dannordquist » Mon Nov 10, 2014 6:44 pm

$Job = Get-VBRJob -name "Tier4d-MD-VM1"
$LastSession = $Job.FindLastSession()
$LastSession | Get-VBRTaskSession | ?{$_.status -eq "Warning"} | select name

Name
----
server01


$TaskSession = $LastSession | Get-VBRTaskSession
$TaskSession.Logger.GetLog().updatedrecords | sort starttime | select title
You cannot call a method on a null-valued expression.
At line:1 char:27
+ $TaskSession.Logger.GetLog <<<< ().updatedrecords | sort starttime | select title
+ CategoryInfo : InvalidOperation: (GetLog:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
dannordquist
Enthusiast
 
Posts: 27
Liked: 2 times
Joined: Thu Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby dannordquist » Mon Nov 10, 2014 9:50 pm

Any idea why I'm getting the null error?

Thank you!
dannordquist
Enthusiast
 
Posts: 27
Liked: 2 times
Joined: Thu Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby v.Eremin » Tue Nov 11, 2014 9:08 am

I've just tried the script and everything seems to have worked properly. Does $TaskSession contain something in your case? Can you just input it and see whether it returns something or not? Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby dannordquist » Tue Nov 11, 2014 12:41 pm

Yes, when I input $TaskSession it returns a list of all the guest server sessions, but the "$TaskSession.Logger.GetLog().updatedrecords | sort starttime | select title" command still returns the null-value error.
dannordquist
Enthusiast
 
Posts: 27
Liked: 2 times
Joined: Thu Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby v.Eremin » Tue Nov 11, 2014 12:51 pm

If $TaskSession contains a list of sessions, try to access just one session that has a problematic VM:

Code: Select all
$TaskSession = $LastSession | Get-VBRTaskSession | where {$_.name -eq "Name of problematic VM"}
$TaskSession.Logger.GetLog().updatedrecords | sort starttime | select title


Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby dannordquist » Tue Nov 11, 2014 12:58 pm 1 person likes this post

Ok, yes, thank you. I can work with that. It returns the details for that vm. Thank you very much!
dannordquist
Enthusiast
 
Posts: 27
Liked: 2 times
Joined: Thu Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby dannordquist » Wed Nov 12, 2014 7:01 pm

Hey Vladimir, quick question... I've been searching the documentation and looking through returned data with different commands and I can't find where to discover if the running job is an incremental or a full. Can you help? Thank you.
dannordquist
Enthusiast
 
Posts: 27
Liked: 2 times
Joined: Thu Oct 23, 2014 3:39 pm
Full Name: Dan Nordquist

Re: how to translate TargetHostID to the guest server name?

Veeam Logoby v.Eremin » Thu Nov 13, 2014 7:12 am

The backup session should have a parameter indicating session type. If my memory serves me well, the parameter is called .IsFullMode:

Code: Select all
$LastSession.IsFullMode


Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Next

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests