Powershell envoyer le fichier en tant que pièce jointe d'un mail

J'ai besoin de vérifier si un fichier existe dans un chemin.

si oui, j'ai besoin de l'envoyer comme pièce jointe de mail.

ce mon code maintenant:

$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 [email protected] -From [email protected] -Subject "test mail" -Body "file name is: $new_file"
}else{
        echo false
}
InformationsquelleAutor rschirin | 2013-04-10