{"id":770,"date":"2009-11-22T23:26:21","date_gmt":"2009-11-23T03:26:21","guid":{"rendered":"http:\/\/wehuberconsultingllc.com\/wordpress\/?p=770"},"modified":"2009-11-22T23:26:21","modified_gmt":"2009-11-23T03:26:21","slug":"updated-script-for-emailing-ntbackup-log-files","status":"publish","type":"post","link":"https:\/\/wehuberconsultingllc.com\/wordpress\/2009\/11\/22\/updated-script-for-emailing-ntbackup-log-files\/","title":{"rendered":"Updated Script for emailing ntbackup log files"},"content":{"rendered":"<p>Jason left a comment on a previous <a href=\"http:\/\/wehuberconsultingllc.com\/wordpress\/2006\/06\/16\/script-for-emailing-ntbackup-log-files\/\">post<\/a> about wanting to see the script I am using to email NTBackup log files. Recently I converted the script to powershell from vbs. Here is the old <a href=\"http:\/\/wehuberconsultingllc.com\/wordpress\/wp-content\/uploads\/2009\/11\/Ntbackup_E-Mail_Alert.vbs_.txt\">file<\/a>.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n#**************************************************\r\n# Script Name: \tNtbackup_E-Mail_Alert\r\n#     Version: \t1.0\r\n#      Author:\tBill Huber\r\n#Last Updated:\t19.Nov.2009\r\n#\r\n#     Purpose:\tConcatenates two or more log files into the body of an email message. I schedule\r\n#\t\t\t\tthis script to run at a time the backup job should be finished and to send me \r\n#\t\t\t\tthe latest NTBackup log files as an email with a somewhat informative subject field.\r\n#\r\n#\t\tLegal:\tPublic Domain.  Modify and redistribute freely.  No rights reserved.\r\n#              \tSCRIPT PROVIDED &quot;AS IS&quot; WITHOUT WARRANTIES OR GUARANTEES OF ANY KIND.\r\n#              \tUSE AT YOUR OWN RISK. NO TECHNICAL SUPPORT PROVIDED.\r\n#**************************************************\r\n\r\n# Customize the following variables for your SMTP server, email from address,\r\n# email address the message is going to, the minimum log size, and the log path.\r\n \r\n$SmtpServer = &quot;mySBServer&quot; \r\n$From = &quot;mySBServer Administrator &lt;administrator @myCompany.com&gt;&quot;\r\n$To = &quot;billhuber@myCompany.com&quot;\r\n$intLogSize = 1000 \t\t#If the log file is less than this size, the backup probably failed\r\n#The following variable point to the log file location\r\n$logpath = &quot;C:\\Documents and Settings\\Administrator\\Local Settings\\Application Data\\Microsoft\\Windows NT\\NTBackup\\data\\*.log&quot;\r\n\r\n# End of Customization\r\n\r\n$SmtpClient = new-object system.net.mail.smtpClient\r\n$SmtpClient.host = $SmtpServer \r\n\r\n#Get the filenames and other stuff for the last two log files\r\n#We are going to concatenate the last two log files into the body of the email message\r\n\r\n$a = get-childitem $logpath | sort-object lastwritetime | select-object -last 2\r\n#Get the last write time for the last report for the subject line\r\n$b = $a | sort-object lastwritetime -descending | select-Object -first 1\r\n$c = $b.LastWriteTime\r\n$d = $b.length\r\n\r\n$Title = &quot;SUCCESS - Full Backup at $c&quot;\r\nif ($d -lt $intLogSize){\r\n\t$Title = &quot;ERROR - Full Backup Failed at $c&quot;\r\n\t}\r\n$Body = &quot;&quot;\r\n foreach ($line in Get-Content $a)\r\n    {\r\n    $Body += &quot;$line `n&quot;\r\n    }\r\n \r\n$SmtpClient.Send($from,$to,$title,$Body)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Jason left a comment on a previous post about wanting to see the script I am using to email NTBackup log files. Recently I converted the script to powershell from vbs. Here is the old file. #************************************************** # Script Name: Ntbackup_E-Mail_Alert # Version: 1.0 # Author: Bill Huber #Last Updated: 19.Nov.2009 # # Purpose: Concatenates &hellip; <a href=\"https:\/\/wehuberconsultingllc.com\/wordpress\/2009\/11\/22\/updated-script-for-emailing-ntbackup-log-files\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Updated Script for emailing ntbackup log files&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-770","post","type-post","status-publish","format-standard","hentry","category-general"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4iN3d-cq","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/posts\/770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/comments?post=770"}],"version-history":[{"count":23,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/posts\/770\/revisions"}],"predecessor-version":[{"id":794,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/posts\/770\/revisions\/794"}],"wp:attachment":[{"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/media?parent=770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/categories?post=770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/tags?post=770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}