HI,
I have a backup job with 2 steps. Step1: Backup the database
Step2: Copy those backup files to Network drive.
Now I my problem is if any mistakes in powershell script it won't run, but SQL server send notification mail Job success, So I need an powershell script when the entire script ran successfully it'll send an email as " COPIED success" Else "Copy Failed - Include powershell message"
My Powershell script:
$path = "E:\Backup"
$des = "\\Network ip\Backup-DR\"
$today = get-date -Format yyyyMMdd
forfiles /p $des /s /m *q* /c "cmd /c Del @path" /d -1
robocopy $path *FULL* $des /e /maxage:$today /XD *LOG*
I have a backup job with 2 steps. Step1: Backup the database
Step2: Copy those backup files to Network drive.
Now I my problem is if any mistakes in powershell script it won't run, but SQL server send notification mail Job success, So I need an powershell script when the entire script ran successfully it'll send an email as " COPIED success" Else "Copy Failed - Include powershell message"
My Powershell script:
$path = "E:\Backup"
$des = "\\Network ip\Backup-DR\"
$today = get-date -Format yyyyMMdd
forfiles /p $des /s /m *q* /c "cmd /c Del @path" /d -1
robocopy $path *FULL* $des /e /maxage:$today /XD *LOG*