I need to check if a file exist into a path.
if yes, I need to send it as attachment of mail.
this my code now:
$file='STREAM_preg.txt'
$pathfile ='c:\Users\root\Desktop'
$dest ='C:\Users\root\Desktop\test'
cd $pathfile
if(Test-Path $file){
$datestamp = get-date -uformat "%Y%m%d%H%M"
Copy-Item $file $dest\$datestamp"_"$file
$new_file = echo $datestamp"_"$file
echo $new_file
# Send-MailMessage -SmtpServer xxxxxxxxxx -To pluto@pippo.com -From preg_new_stream@pippo.com -Subject "test mail" -Body "file name is: $new_file"
}else{
echo false
}