Hi,
I am new here and this is my first experience with Powershell. My task is it to write a script which looks in a specified Directory for Files and should report me if there are files.
This is my script:
function Send-Mail { param($SmtpServer,$From,$To,$Subject,$Body)
$smtp = new-object system.net.mail.smtpClient($SmtpServer) $mail = new-object System.Net.Mail.MailMessage $mail.from= $From $mail.to.add($To) $mail.subject = $Subject $mail.body= $Body $smtp.send($mail) }
$Directory = "Path to folder"
$MailForm = "Sender Address" $PSEmailServer = "SMTP Server"
$Data = get-childitem $Directory -force -name $Counter = $Data.count if($Counter -gt $null) { $Subject="Your Subject!!!" $Body = "Your Text!!!" Send-MailMessage -From $MailForm -To $MailForm -Subject $Subject -Body $Body }
The problem with my script is that it only runs if the folder contains more then one data file but it should report me if there are data files in it or not considering all data files.
|