Updated Script for emailing ntbackup log files

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 two or more log files into the body of an email message. I schedule
#				this script to run at a time the backup job should be finished and to send me 
#				the latest NTBackup log files as an email with a somewhat informative subject field.
#
#		Legal:	Public Domain.  Modify and redistribute freely.  No rights reserved.
#              	SCRIPT PROVIDED "AS IS" WITHOUT WARRANTIES OR GUARANTEES OF ANY KIND.
#              	USE AT YOUR OWN RISK. NO TECHNICAL SUPPORT PROVIDED.
#**************************************************

# Customize the following variables for your SMTP server, email from address,
# email address the message is going to, the minimum log size, and the log path.
 
$SmtpServer = "mySBServer" 
$From = "mySBServer Administrator <administrator @myCompany.com>"
$To = "billhuber@myCompany.com"
$intLogSize = 1000 		#If the log file is less than this size, the backup probably failed
#The following variable point to the log file location
$logpath = "C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\*.log"

# End of Customization

$SmtpClient = new-object system.net.mail.smtpClient
$SmtpClient.host = $SmtpServer 

#Get the filenames and other stuff for the last two log files
#We are going to concatenate the last two log files into the body of the email message

$a = get-childitem $logpath | sort-object lastwritetime | select-object -last 2
#Get the last write time for the last report for the subject line
$b = $a | sort-object lastwritetime -descending | select-Object -first 1
$c = $b.LastWriteTime
$d = $b.length

$Title = "SUCCESS - Full Backup at $c"
if ($d -lt $intLogSize){
	$Title = "ERROR - Full Backup Failed at $c"
	}
$Body = ""
 foreach ($line in Get-Content $a)
    {
    $Body += "$line `n"
    }
 
$SmtpClient.Send($from,$to,$title,$Body)