PowerShell script exchange
Post Reply
dinger76
Enthusiast
Posts: 29
Liked: 1 time
Joined: Nov 26, 2009 11:46 am
Full Name: Chris Bell
Contact:

Start/Finish Times & Per VM times

Post by dinger76 »

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
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Start/Finish Times & Per VM times

Post by Sethbartlett »

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.
dinger76
Enthusiast
Posts: 29
Liked: 1 time
Joined: Nov 26, 2009 11:46 am
Full Name: Chris Bell
Contact:

Re: Start/Finish Times & Per VM times

Post by dinger76 »

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
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Start/Finish Times & Per VM times

Post by ThomasMc »

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
dinger76
Enthusiast
Posts: 29
Liked: 1 time
Joined: Nov 26, 2009 11:46 am
Full Name: Chris Bell
Contact:

Re: Start/Finish Times & Per VM times

Post by dinger76 »

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
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Start/Finish Times & Per VM times

Post by Sethbartlett »

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.
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Start/Finish Times & Per VM times

Post by ThomasMc »

All those .dll look very suspicious , look like random names coupled with the fact they are suppose to be in your temp folder.
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Start/Finish Times & Per VM times

Post by Sethbartlett »

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.
dinger76
Enthusiast
Posts: 29
Liked: 1 time
Joined: Nov 26, 2009 11:46 am
Full Name: Chris Bell
Contact:

Re: Start/Finish Times & Per VM times

Post by dinger76 »

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
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests