Hello All,
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?
$MyFileList = @( "DatabaseName_Full_20180206.bak.zip" ) $Current = gci "DIRECTORYNAME" -Recurse -File -Exclude '*.done','*.txt' | ?{$_.LastWriteTime -gt (Get-Date).AddDays(-1)} $Databases = 0 $MyFileList |foreach { If (($Current).Name -contains $_) { ++$Databases } else { Write-Host "$_ is missing" } } If ($Databases -eq 24 ) { Write-Output "Databases OK" }