In my script I use try/catch/finally logic to open a restore session, then close it. The script looks like this:
Code: Select all
try {
…
Start-VESQLRestoreSession -RestorePoint $restorepoint[-1];
$session = Get-VESQLRestoreSession;
…
if ( $session[0] )
{
Stop-VESQLRestoreSession -Session $session[0];
}
}
catch {
…
}
finally {
if ( $session[0] )
{
Stop-VESQLRestoreSession -Session $session[0];
}
Disconnect-VBRServer;
}
How can I check for that, so I don't try to stop the restore session if it is stopped already?