PowerShell script exchange
Post Reply
cstaubli
Service Provider
Posts: 10
Liked: 2 times
Joined: Feb 08, 2013 8:45 am
Full Name: Christian
Contact:

Get Statistics subtask with powershell

Post by cstaubli » Jul 03, 2013 7:05 am

Hello all

I'm looking for a way to get some information from job statistics via powershell. Especially I'm interested in removing vm snapshot time for each VM in a certain job. In GUI you can right click a job, choose statistics, select a VM and scroll down to this entry. Is it possible or do I have to look for this information directly in DB?

Thanks in advance
Christian

cstaubli
Service Provider
Posts: 10
Liked: 2 times
Joined: Feb 08, 2013 8:45 am
Full Name: Christian
Contact:

Re: Get Statistics subtask with powershell

Post by cstaubli » Jul 03, 2013 7:45 am 1 person likes this post

Nevermind, I found a solution:

Code: Select all

$Jobs = Get-VBRJob -Name "Name*"
foreach ($Job in $Jobs) {
	$LastSession = $Job.FindLastSession()
	$TaskSessions = $LastSession | Get-VBRTaskSession
	foreach ($vm in $TaskSessions) {
		$asd = $vm.Logger.GetLog().UpdatedRecords | where-object {$_.title -eq "Removing VM snapshot"} | Select-Object title, starttime, updatetime
		$diff = $asd.updatetime - $asd.starttime
		Write-Host $vm.Name `t $diff.TotalMinutes
	}
}

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get Statistics subtask with powershell

Post by veremin » Jul 03, 2013 10:28 am

I have to admit you wrote a nice script, indeed. Thanks for sharing it with the community; highly appreciated.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests