PowerShell script exchange
Post Reply
efd121
Enthusiast
Posts: 67
Liked: 6 times
Joined: Aug 07, 2015 8:45 pm
Full Name: David Engler
Contact:

Get-VBRRestoreSession object

Post by efd121 »

I'm trying to track down information from restore sessions but I'm not able to find some of the information in the PS restore session object that is in the GUI. Looking at the log tab from the GUI from a failed session the last two entries are "Session became orphaned" and "Restore job is failed: Restore session closed unexpectedly" Does anyone know where I can find this information from the history of the restore sessions?
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get-VBRRestoreSession object

Post by veremin »

Can you tell me what type of restore session was executed: FLR, Instant VM Recovery, Full VM Recovery, Tape Recovery, etc.? Thanks!
efd121
Enthusiast
Posts: 67
Liked: 6 times
Joined: Aug 07, 2015 8:45 pm
Full Name: David Engler
Contact:

Re: Get-VBRRestoreSession object

Post by efd121 »

File level restore
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get-VBRRestoreSession object

Post by veremin »

Then, you can use something like this (should output restore session log):

Code: Select all

Asnp VeeamPSSNapin
$RestoreSession = Get-VBRRestoreSession | sort creationtimeutc -Descending | select -First 1
$RestoreSession.Logger.Getlog().updatedrecords.title
Thanks!
efd121
Enthusiast
Posts: 67
Liked: 6 times
Joined: Aug 07, 2015 8:45 pm
Full Name: David Engler
Contact:

Re: Get-VBRRestoreSession object

Post by efd121 »

Thanks for the quick response, I will give this a try
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get-VBRRestoreSession object

Post by veremin »

The script assumes that the session you need to query is the latest executed one. If that's not true, add some filter parameter: creation time, VM name or similar. Thanks!
efd121
Enthusiast
Posts: 67
Liked: 6 times
Joined: Aug 07, 2015 8:45 pm
Full Name: David Engler
Contact:

Re: Get-VBRRestoreSession object

Post by efd121 »

Thanks, I am able to get the information I'm looking for. I have an open case where it appears for some of the failed FLR restores its causing scheduled jobs not to start.

Using the code you provided I was able to find a log entry "Exception of type 'Veeam.Backup.AgentProvider.AgentClosedException' was thrown." So far I have found at least one example of this on the days we have experienced the scheduled job issue.

I have other failed FLR sessions that do not contain this Exception but they are not causing the scheduled jobs to stop running.
efd121
Enthusiast
Posts: 67
Liked: 6 times
Joined: Aug 07, 2015 8:45 pm
Full Name: David Engler
Contact:

Re: Get-VBRRestoreSession object

Post by efd121 » 1 person likes this post

Adding a portion of my script in case someone else could use it. I used the same code minus the -and $restoreSession.Result -eq "Failed" and log information to pull back a csv from the past year of FLR restores. Parsing the data I found that our SD has ran over 400 restores from the same server, looks like I found my next script to automate those restores for them :)

Code: Select all

$restoreSessions = Get-VBRRestoreSession
foreach ($restoreSession in $restoreSessions)
	{
	$item = "" | Select Server, RestorePoint, Start, End, Who, Result, Log
	if ($restoreSession.JobType -eq "FileLevelRestore" -and $restoreSession.Result -eq "Failed")
		{
		$item.Server = $restoreSession.Info.VmDisplayName
		$item.RestorePoint = $restoreSession.Info.OibCreationTime
		$item.Start = $restoreSession.CreationTime
		$item.End = $restoreSession.EndTime
		$item.Who = $restoreSession.Info.Initiator.Name
		$item.Result = $restoreSession.Result
		$tmplog = $restoreSession.Logger.GetLog().updatedrecords.title
		foreach ($log in $tmplog)
			{
			$item.Log += $log
			$item.Log += ","
			}
		$results += $item
		}
	}
$results | Export-Csv $resultsFile -NoTypeInformation
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get-VBRRestoreSession object

Post by veremin »

Thanks for sharing the resulting script with fellow forum members; appreciated!
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests