Script to check for daily backup file and email is none exist

Need a script I can schedule daily to verify that a backup file exists on the local machine. If it doesn't exist then it needs to use blat or some similar solution to email a notification about the missing backup file. The location of the backup will be C:\VTBackups\ and the filename structure is VtDb_VT_YYYYMMDD_21_00_00.Bak, so the backup for today would have been VtDb_VT_20180828_21_00_00.Bak.
murrycAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
function send-myemail 
{
  [CmdletBinding()]
     Param 
    (
    [String]$today,
    [String]$ToAddress = 'admin@example.com',
    [String]$FromAddress = 'administrator@example.com',
    [String]$SmtpServer = 'smtp.office365.com',
    [int]$SmtpPort = 587
     )


  $emailParams = @{
    To = $ToAddress
    Subject = 'Backup Failure ' + $today
    Body =  'Backup File not Found'
    From = $FromAddress
    smtpserver= $SmtpServer
    Port = $SmtpPort
    Credential = $smtpcred
    #Attachments = $Attachment
  }
  Send-MailMessage @mailparam -UseSsl
  }
  
$path = 'C:\VTBackups\VtDB_VT_'
$today = get-date -Format "yyyyMMdd"
$result = get-childitem -Path ($path + $today+ "*")
if($result.count -lt 1){
  send-myemail $today
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David Johnson, CD, MVPOwnerCommented:
asked and answered
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.