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

Get Statistics subtask with powershell

Post by cstaubli »

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: 13
Liked: 2 times
Joined: Feb 08, 2013 8:45 am
Full Name: Christian
Contact:

Re: Get Statistics subtask with powershell

Post by cstaubli » 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: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get Statistics subtask with powershell

Post by veremin »

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: Google [Bot] and 15 guests