I am fairly new to powershell and and the forum, however I have been tasked with trying to find/build a script to pull via Powershell to be run via task scheduler.
I have already found this powershell-f26/powershell-script-to-lis ... 49222.html forum post however any attempts at trying to bend it to what we need has failed so i had kind of had to resort to building my own.
Here's the code I have cobbled together using the other forum post as a reference whilst trying to understand what's going on with each part so I can learn more, whilst I fulfil the task. The end result will go out to CSV/Email at the end in order for it to be added to our tracking system, I have the CSV bit working in my version so have omitted that from here, VM name changes have also taken place.
The main areas i need to show are the affected Vm's, the Date of the backup, the state is incomplete, location and which repository it sits in. At the minute the focus is on just standard Repo's but there are plans to make use of SOBR's which I suspect and from reading around this type of script could be a problem.
I am still working on the script (still working out how to link and name repo's) but I have currently hit my limit, as I am struggling to work out how to output the "Filepath" from the $mybackups.getallstorages() section as part of the final output.. if I use my variable $mybackupstest i get the "creation time" and "filepath", however like in my Code below if I use the $myrestorepoints I get all three but not the "filepath".
Code: Select all
$mybackups = get-vbrbackup | ?{$_.JobType -eq "BackupSync"}
$myrestorepoints = $mybackups | Get-VBRRestorePoint | ?{$_.IsConsistent -eq $false}
foreach ($myRestorepoint in $myrestorepoints) {
foreach ($mybackupstest in $mybackups.getallstorages()) {
$myCompare = $myrestorepoints | ?{$_.BackupId -eq $mybackups.Id -and $myrestorepoints.IsConsistent -eq $false}
}
}
$myrestorepoints = $myrestorepoints | Sort-object -Property BackupId
$myrestorepoints | select -Property VmName,CreationTime,IsConsistent,FilePath | Fortmat-table
VmName CreationTime IsConsistent FilePath
------ ------------ ------------ --------
vmname1 05/08/2020 22:46:31 False
vmname2 05/08/2020 22:33:38 False
vmname3 05/08/2020 22:39:24 False
vmname4 05/08/2020 22:41:52 False