Natürlich muss es vorher auf die örtlichen Gegebenheiten angepasst werden (Daten zum Mailserver sowie Mailadressen).
Code: Alles auswählen
# Variablen
$DateFormat = Get-Date -format yyyyMMdd-HH-mm
$Logfile = "D:\Logs\wsus-bereinigung-$DateFormat.log"
# WSUS Bereinigung durchführen
Invoke-WsusServerCleanup -CleanupObsoleteComputers -CleanupObsoleteUpdates -CleanupUnneededContentFiles -CompressUpdates -DeclineExpiredUpdates -DeclineSupersededUpdates | Out-File $Logfile
# Mail Variablen
$MailSMTPServer = "mail.domain.local"
$MailFrom = "administrator@domain.de"
$MailTo = "it-support@domain.de"
$MailSubject = "${env:COMPUTERNAME} WSUS-Bereinigung $DateFormat"
$MailBody = Get-Content $Logfile | Out-String
# Mail versenden
Send-MailMessage -SmtpServer $MailSMTPServer -From $MailFrom -To $MailTo -subject $MailSubject -body $MailBody -Encoding Unicode