Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $error.clear()
- ##$erroractionpreference = "SilentlyContinue"
- $24_hrs_ago = ($(get-date).AddDays(-1)) # -format 'yyyy-MM-dd__HH-mm-ss'
- $pretty_today = get-date -format 'yyyyy-MM-dd__HH-mm-ss'
- $total_files = 0
- $new_files = 0
- $folder = 'D:\Veeam Backups\'
- $vrbs = 0
- $include_ext = '.vrb'
- $EXE_STR = ' '
- $email_to = 'EMAIL@email.com'
- # $email_to = 'EMAIL@email.com'
- $email_from = 'EMAIL@email.com'
- $subject = '[ERROR] FAILED MSG GOES HERE'
- $body = 'Unable to find new incremental files from the past 24 hours to archive with TSM.'
- $smtp = 'smtp.email.com'
- $log_file = 'c:\scripts\logs\FILENAME.log'
- "---------------------------------------------" | Out-File $log_file -append
- "--- new file check: " + $pretty_today + " ---" | Out-File $log_file -append
- "---------------------------------------------" | Out-File $log_file -append
- foreach ($i in Get-ChildItem $folder)
- {
- $total_files++
- if ($i.extension -eq $include_ext)
- {
- $vrbs++
- if ($i.CreationTime -gt $24_hrs_ago)
- {
- $new_files++
- if ($new_files -eq 1) # just for log formatting
- {
- " " | Out-File $log_file -append
- " NEW FILES: " | Out-File $log_file -append
- }
- # add command to execute backup thinger here
- ' -->' + $i.FullName | Out-File $log_file -append
- & 'C:\Program Files\Tivoli\TSM\baclient\dsmc.exe' archive -archmc=ARCHIVE7DAYS $i.FullName
- }
- }
- }
- if ($new_files -le 0)
- {
- send-mailmessage -to $email_to -from $email_from -subject $subject -body $body -priority High -dno onSuccess, onFailure -smtpServer $smtp
- }
- else
- {
- " " | Out-File $log_file -append
- }
- " TOTAL FILES ............................ " + $total_files | Out-File $log_file -append
- " " + $include_ext + " Files ............................. " + $txts | Out-File $log_file -append
- " " + $include_ext + " Files Since " + $24_hrs_ago + " ... " + $new_files | Out-File $log_file -append
- "------------------------------------------------" | Out-File $log_file -append
- " " | Out-File $log_file -append
- " " | Out-File $log_file -append
Add Comment
Please, Sign In to add comment