Re: robocopy email benachrichtigung
Verfasst: 13. Mai 2014, 23:31
lässt du mehrere Robocopy-Jobs "gleichzeitig" laufen ?
passiert das auch beim Einzelschritt durchsteppen ?
passiert das auch beim Einzelschritt durchsteppen ?
Die Anlaufstelle für alle Windows Home Server Administratoren und Anwender
https://forum.home-server-blog.de/
Code: Alles auswählen
$Logfile = "C:\Logs\Backup.log" + (Get-Date).tostring("yyyy-MM-dd") + ".log"
Nobby1805 hat geschrieben:Log-Datei öffnen
Ziel-Daten anlegen
im Loop für alle Zeilen ... Zeile lesen ... umformatieren ... Zeile schreiben
Beide Dateien schließen
am Besten du suchst dir eine Einführung in Powershell und schaust dir erstmal die Möglichkeiten an
Code: Alles auswählen
-command c:\logs\robocopy\Sicherung_Mila.ps1 -noexit
Code: Alles auswählen
powershell
Code: Alles auswählen
# **************************************************************
# * PowserShell Script *
# **************************************************************
# * Script: *
# * PowerShell Robocopy script with e-mail notification *
# * e-mail notification with SSL support *
# **************************************************************
# * Autor: *
# * D. Stastka, 2011-12-28 *
# **************************************************************
# Variables Backup
$SourceFolder = "F:\"
$DestinationFolder = "\\SERVER-BACKUP\Server-Backup\Sicherung_F"
$Logfile = "C:\Logs\Backup.log" + (Get-Date).tostring("yyyy-MM-dd") + "_Sicherung_F" + ".log"
# Variables Email notification
$EmailFrom = "ddd"
$EmailTo = "hhh"
$EmailBody = "Robocopy completed successfully. See attached log file for details"
$EmailSubject = "Robocopy Job"
$SMTPServer = "smtp.web.de"
$SMTPPort = "587"
$Username = "ddd"
$Password = "hhh"
# Mirror Folder with Robocopy
Robocopy $SourceFolder $DestinationFolder /xd "System Volume Information" $recycle.bin /xf pagefile.sys NTUSER.Dat /mir /a-:sh /fft /LOG:$Logfile /NDL /TEE
# Send E-mail message with log file attachment
$Message = New-Object Net.Mail.MailMessage($EmailFrom, $EmailTo, $EmailSubject, $EmailBody)
$Attachment = New-Object Net.Mail.Attachment($Logfile, 'text/plain')
$Message.Attachments.Add($Attachment)
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, $SMTPPort)
If (-not ($SMTPPort -eq "25")){
$SMTPClient.EnableSsl = $true;
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
}
$SMTPClient.Send($Message)
# EOF
Code: Alles auswählen
# **************************************************************
# * PowserShell Script *
# **************************************************************
# * Script: *
# * PowerShell Robocopy script with e-mail notification *
# * e-mail notification with SSL support *
# **************************************************************
# * Autor: *
# * D. Stastka, 2011-12-28 *
# **************************************************************
# Variables Backup
$SourceFolder = "G:\ServerFolders\Videos\Sonstige\Mila"
$DestinationFolder = "H:\Sicherung_Mila"
$Logfile = "C:\Logs\Backup.log" + (Get-Date).tostring("yyyy-MM-dd") + "_Sicherung_Mila" + ".log"
# Variables Email notification
$EmailFrom = "ddd"
$EmailTo = "hhh"
$EmailBody = "Robocopy completed successfully. See attached log file for details"
$EmailSubject = "Robocopy Job"
$SMTPServer = "smtp.web.de"
$SMTPPort = "587"
$Username = "ddd"
$Password = "hhh"
# Mirror Folder with Robocopy
Robocopy $SourceFolder $DestinationFolder /xd "System Volume Information" $recycle.bin /xf pagefile.sys NTUSER.Dat /mir /a-:sh /fft /LOG:$Logfile /NDL /TEE
# Send E-mail message with log file attachment
$Message = New-Object Net.Mail.MailMessage($EmailFrom, $EmailTo, $EmailSubject, $EmailBody)
$Attachment = New-Object Net.Mail.Attachment($Logfile, 'text/plain')
$Message.Attachments.Add($Attachment)
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, $SMTPPort)
If (-not ($SMTPPort -eq "25")){
$SMTPClient.EnableSsl = $true;
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
}
$SMTPClient.Send($Message)
# EOF