Start/Finish Times & Per VM times

PowerShell script exchange

Start/Finish Times & Per VM times

Veeam Logoby dinger76 » Wed Jan 04, 2012 2:51 pm

Hi,

In my quest to go through and create a usable report for Veeam to provide a report on a per VM basis, I'm now in a position to use some of the new functionality in v6 and powershell.

I've been scouring over the forums for most of the day trying out different elements to perform this reporting but seem to have problems getting the Start Times and Finish Times for the jobs (or ideally for the virtual machines). I have seen other people use the Get-JobStatistics cmdlet but this does not seem to be known in my v6 installation. Is there a simple way to get the job listed, with details of start time/finish time, duration etc. and then below it, the individual virtual machines with similar information.

Any assistance would be appreciated.

Thanks

Chris
dinger76
Enthusiast
 
Posts: 28
Liked: 1 time
Joined: Thu Nov 26, 2009 11:46 am
Full Name: Chris Bell

Re: Start/Finish Times & Per VM times

Veeam Logoby Sethbartlett » Wed Jan 04, 2012 3:45 pm

You need to grab your sessions data and parse through some XML:

Code: Select all
$Session = Get-VBRBackupSession -name "Name of session"
$Session.Logger.GetLog()


You can also then do:
Code: Select all
$Session.GetTaskSessions()


This will give you a list of VMs, you can then do:

Code: Select all
$vm = ($session.GetTaskSession)[0]
$vm.Logger.GetLog()


This will give you start time, proxy information, etc for each VM.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Start/Finish Times & Per VM times

Veeam Logoby dinger76 » Sun Jan 08, 2012 7:25 pm

Hi Seth,

I must be missing something, I'm fairly new to Powershell but I receive the following error when trying to do the commands you specified:

You cannot call a method on a null-valued expression.
At D:\scripts\test4.ps1:9 char:23
+ $Session.Logger.GetLog <<<< ()
+ CategoryInfo : InvalidOperation: (GetLog:String) [], RuntimeExc
eption
+ FullyQualifiedErrorId : InvokeMethodOnNull

This is whilst running the following code, on v6:


$jobs = Get-VBRJob | where {$_.jobtargettype -eq “Backup”} | sort name

foreach ($job in $jobs) {

$Session = Get-VBRBackupSession -Name $job.Name
$Session.Logger.GetLog()

}

Please help

Cheers
dinger76
Enthusiast
 
Posts: 28
Liked: 1 time
Joined: Thu Nov 26, 2009 11:46 am
Full Name: Chris Bell

Re: Start/Finish Times & Per VM times

Veeam Logoby ThomasMc » Sun Jan 08, 2012 8:43 pm

Your retrieving to many sessions to use the GetLog() in the current script, if its just the last session of all the jobs that are backups then something like this is what you need

Code: Select all
$jobs = Get-VBRJob | ?{$_.IsBackup}
$logAry = @()
foreach ($job in $jobs) {
   $logAry = $logAry + $job.FindLastSession().Logger.GetLog()
}

$logAry[0].UpdatedRecords # First Log
$logAry[1].UpdatedRecords # Second Log
$logAry[2].UpdatedRecords # Third and so on


Or loop through your $Session Object
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Start/Finish Times & Per VM times

Veeam Logoby dinger76 » Mon Jan 09, 2012 1:01 pm

Thanks for the reply, it does make sense but I do get some DLL error messages when running the script, thanks:

Exception calling "GetLog" with "0" argument(s): "Could not find file 'C:\Users
\username\AppData\Local\Temp\2\uko4l-mg.dll'."
At D:\scripts\test4.ps1:4 char:60
+ $logAry = $logAry + $job.FindLastSession().Logger.GetLog <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

Exception calling "GetLog" with "0" argument(s): "Could not find file 'C:\Users
\username\AppData\Local\Temp\2\uumzsm-3.dll'."
At D:\scripts\test4.ps1:4 char:60
+ $logAry = $logAry + $job.FindLastSession().Logger.GetLog <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

Exception calling "GetLog" with "0" argument(s): "Could not find file 'C:\Users
\username\AppData\Local\Temp\2\ab36vnzw.dll'."
At D:\scripts\test4.ps1:4 char:60
+ $logAry = $logAry + $job.FindLastSession().Logger.GetLog <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

Exception calling "GetLog" with "0" argument(s): "Could not find file 'C:\Users
\username\AppData\Local\Temp\2\oxhayyve.dll'."
At D:\scripts\test4.ps1:4 char:60
+ $logAry = $logAry + $job.FindLastSession().Logger.GetLog <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

Exception calling "GetLog" with "0" argument(s): "Could not find file 'C:\Users
\username\AppData\Local\Temp\2\irxghhgr.dll'."
At D:\scripts\test4.ps1:4 char:60
+ $logAry = $logAry + $job.FindLastSession().Logger.GetLog <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

Exception calling "GetLog" with "0" argument(s): "Could not find file 'C:\Users
\username\AppData\Local\Temp\2\-ppjsbdb.dll'."
At D:\scripts\test4.ps1:4 char:60
+ $logAry = $logAry + $job.FindLastSession().Logger.GetLog <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
dinger76
Enthusiast
 
Posts: 28
Liked: 1 time
Joined: Thu Nov 26, 2009 11:46 am
Full Name: Chris Bell

Re: Start/Finish Times & Per VM times

Veeam Logoby Sethbartlett » Mon Jan 09, 2012 1:38 pm

Can you go through each of these commands and make sure they work?

Code: Select all
$Job = (Get-VBRJob | ?{$_.Isbackup)[0]
$Session = $Job.FindLastSession()
$Log = $Session.Logger.GetLog()


If these fail, please open a case with support and state my name(Seth Bartlett) in the initial ticket so I can take a look at it.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Start/Finish Times & Per VM times

Veeam Logoby ThomasMc » Mon Jan 09, 2012 2:35 pm

All those .dll look very suspicious , look like random names coupled with the fact they are suppose to be in your temp folder.
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Start/Finish Times & Per VM times

Veeam Logoby Sethbartlett » Mon Jan 09, 2012 2:37 pm

I agree, they look very "virus-y" from my experience. Random names/numbers are typically a bad thing :P
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Start/Finish Times & Per VM times

Veeam Logoby dinger76 » Tue Jan 10, 2012 11:11 am

Ok, went through and entered the lines individually as requested. The first two lines went through okay and then the logger line came up with the following error:

PS D:\scripts> $Job = (Get-VBRJob | ?{$_.Isbackup})[0]
PS D:\scripts> $Session = $Job.FindLastSession()
PS D:\scripts> $Log = $Session.Logger.GetLog()
Exception calling "GetLog" with "0" argument(s): "Could not find file 'C:\Users
\cb55090\AppData\Local\Temp\2\glteo-8e.dll'."
At line:1 char:30
+ $Log = $Session.Logger.GetLog <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

Taking your suggestion that this could be virus related, I downloaded and used the McAfee Stinger program this morning, no infected files found. This is on top of Symantec Endpoint Protection 11 being installed on the machine as well.

I've just gone through and closed the PowerShell sessions and opened new ones to make sure that everything is cleared on the machine... this time each line of the code worked as expected.

I have also then gone through the full script that you published earlier in this thread again and this processed correctly as well. It was my fault for reusing an existing Powershell session from testing out other items.

Thanks
dinger76
Enthusiast
 
Posts: 28
Liked: 1 time
Joined: Thu Nov 26, 2009 11:46 am
Full Name: Chris Bell


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 4 guests