I have wrote the below script to check that all of our manually backed up databases are present in the backup directory and have been written within the last 24 hours. The script works as intended (Happy with any input to improve it.) however, the sql backup appends the files with the date of the backup, this cannot be removed as it is apparently required by the development team. The problem with this is that the backup time spans across two date ranges as it runs late at night till early morning. Is there any way to add a wildcard into the name so that it does not care about the date?
I would recommend to specify the files you're after with a -Filter that includes the files you want and not to exclude everything else. If you need to compare objects you could use Compare-Object. I would "outsource" the file list to a csv file. That makes it easier to maintain it. So my approach would be something like this:
What I didn't get is what you mean with "add a wildcard into the name so that it does not care about the date". Instead of using the LastWriteTime you could use CreationTime. Or you could use the time stamp included in the file name.