Quantcast
Channel: R&D Forums
Viewing all articles
Browse latest Browse all 9961

PowerShell • Re: List database in backup from PowerShell

$
0
0
Hi @david.domask,

There is a current version of the script (created by a previous colleague) that I need to update to support Veeam 12.1, but the more I try to find a brief solution that will support the current script, the more I see that this script needs to be rewritten. I will start on a new script based on your previous suggestion. Anyway, thank you very much for your help. Here is the original part of the script from where you can see why I need an ID column:

Code:

$job = Get-VBRJob -Name $jobName -WarningAction SilentlyContinue$jobBackup = GetLastBackup -job $job$rps = Get-VBRRestorePoint -Backup $jobBackup$vmNames = $rps | select name -Unique$device = $vmNames.name$rp = $rps | where {$_.Name -eq $device} | Sort-Object -Descending CreationTime | Select-Object -First 1#this (now unsupported) method will give us ID column$gdb = $jobBackup.GetGuestDatabases($rp.ObjectId) | ?{-not $_.isSystem}If ($rp -ne $null -and $gdb -ne $null){#from here we are getting column GuestDbId$dbOibs = $rp.GetGuestDatabaseToOibLinks()#here we compare GuestDbId column from $dbOibs and column ID from $gdb to create a new array$dbs = $dbOibs | Join-Object -On $gdb -Where {$a.GuestDbId -eq $b.id -and -not $b.isSystem} -Select {@{"Name"=$b.Dbname;"Servername"=$b.ServerName; "InstanceName"=$b.InstanceName;"ObjId"=$b.ObjectId; "RestorePointId"=$a.oibId;"dbGuid"=$b.id}}write-log "$($dbs.Count) Dbs found for device [$device]"$dbs| ForEach-Object {$dbKey = "$($_.serverName)_$($_.instanceName)_$($_.name)"$obj = New-Object System.Object | select planName, deviceName, database, guid, state$obj.PlanName = $job.Name$obj.deviceName = $device$obj.database = $dbKey$obj.state = $state$obj.guid = "$($_.name)-$($_.dbGuid)"$data += $obj}}

Statistics: Posted by vlad.p — Jan 24, 2024 10:52 am



Viewing all articles
Browse latest Browse all 9961

Latest Images

Trending Articles



Latest Images