Hallo Zusammen, ich baue aktuell an einer MDT Umgebung, die neben dem OSD auch Softwareinstallationen und Windows Updates im laufenden Betrieb ausführen soll.
Hierbei möchten wir grundsätzlich per Email benachrichtigt werden. Wenn in der Task sequenz Fehler auftreten wird die geparste Results.xml, welche normalerweise im Summarywizzard angezeigt wird mit gesendet.
Sobald ein Fehler oder eine Warnung auftritt wird die Existenz von folgenden Logfiles überprüft und alle existenten werden angehängt.
- C:\Windows\Temp\DeploymentLogs\LiteTouch.log
- C:\Windows\Temp\DeploymentLogs\ZTIGather.log
- C:\Users\Administrator\AppData\Local\Temp\smsts.log
- C:\Users\Administrator\AppData\Local\Temp\SMSTSLog\smsts.log
- C:\Windows\Temp\BDDLogs\LiteTouch.log
- C:\Windows\Temp\BDDLogs\BDD.log
- C:\_SMSTaskSequence\smsts.log
- X:\MININT\SMSOSD\OSDLOGS\BDD.LOG
- X:\MININT\SMSOSD\OSDLOGS\smsts.LOG
- C:\MININT\SMSOSD\OSDLOGS\smsts.LOG
- C:\MININT\SMSOSD\OSDLOGS\BDD.LOG
Dazu habe ich zur litetouch.wsf (Im Scripts Verzeichnis eures Deploymentshares) folgende Sub ergänzt:
Sub SummaryEmail
If UCase(oEnvironment.Item("SummaryEmailEnable")) = "YES" then
' Email Parameters
Dim oMessage
Dim Logs
Dim lgf
Dim strTextBody
Dim strSubject
Dim emailoResults
Dim emailiRetVal
Dim emailiErrors
Dim emailiWarnings
Dim emailsBuffer
Dim emailsDeploymentType
Logs = Array("C:\Windows\Temp\DeploymentLogs\BDD.log", "C:\Windows\Temp\DeploymentLogs\LiteTouch.log", "C:\Windows\Temp\DeploymentLogs\ZTIGather.log", "C:\Users\Administrator\AppData\Local\Temp\smsts.log", "C:\Users\Administrator\AppData\Local\Temp\SMSTSLog\smsts.log","C:\Windows\Temp\BDDLogs\LiteTouch.log","C:\Windows\Temp\BDDLogs\BDD.log", "C:\_SMSTaskSequence\smsts.log", "X:\MININT\SMSOSD\OSDLOGS\BDD.LOG","X:\MININT\SMSOSD\OSDLOGS\smsts.LOG", "C:\MININT\SMSOSD\OSDLOGS\smsts.LOG", "C:\MININT\SMSOSD\OSDLOGS\BDD.LOG" )
If oFSO.FileExists(oEnv("TEMP") & "\Results.xml") then
Set emailoResults = oUtility.CreateXMLDOMObjectEx(oEnv("TEMP") & "\Results.xml")
emailiErrors = CInt(oUtility.SelectSingleNodeString(emailoResults, "//Errors"))
emailiWarnings = CInt(oUtility.SelectSingleNodeString(emailoResults, "//Warnings"))
emailsBuffer = oUtility.SelectSingleNodeString(emailoResults, "//Messages")
emailiRetVal = oUtility.SelectSingleNodeString(emailoResults, "//RetVal")
emailsDeploymentType = oUtility.SelectSingleNodeString(emailoResults, "//DeploymentType")
Else
emailiErrors = 0
emailiWarnings = 1
emailsBuffer = "Unable to locate the Results.xml file needed to determine the deployment results. "
emailsBuffer = emailsBuffer & "(This may be the result of mismatched script versions. Ensure all boot images have been updated.)"
End if
strTextBody = "Errors:" & emailiErrors & "
" & "Warnings:" & emailiWarnings & "
Result:
" & emailsBuffer
strSubject = "MDT Deployment " & oEnvironment.Item("_SMSTSPackageName") &" finished on " & oEnvironment.Item("OSDComputerName") & " with " & emailiErrors & " Errors, " & emailiWarnings & " Warnings"
Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = oEnvironment.Item("SummaryEmailRelay")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = oEnvironment.Item("SummaryEmailRelayPort")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = FALSE
oMessage.Configuration.Fields.Update
oMessage.Subject = strSubject
oMessage.From = oEnvironment.Item("SummaryEmailFrom")
oMessage.To = oEnvironment.Item("SummaryEmailTo")
oMessage.HTMLBody = strTextBody
If emailiWarnings > 0 Or emailiErrors > 0 Then
For each lgf in Logs
If oFSO.FileExists(lgf) then
oMessage.AddAttachment lgf
End if
Next
End If
oMessage.Send
End if
End Sub
Diese kann in der Litetouch.wsf am Ende VOR folgenden Zeilen eingefügt werden:
End Class
Zudem muss vor beenden des Litetouch scripts die Sub aufgerufen werden.
Ca bei Zeile 980 beginnt Folgender Abschnitt:
' Display the final summary wizard (unless skipped) If (not bSkipFinalSummary) or iRetVal <> 0 then If bIsServerCoreOS then If iRetVal = 0 then oShell.Popup "Deployment completed successfully. Review deployment logs for full details.", 0, "Successful Deployment", 64 Else oShell.Popup "Deployment did not complete successfully. Review deployment logs for full details.", 0, "Failed Deployment", 48 End if ...................................
Die Sub sollte mit dem folgenden Kommando diekt vor diesen Zeilen eingebunden werden. Somit wird sie auch ausgeführt wenn der Summarywizzard erscheint und auf Nutzerinteraktion wartet.
SummaryEmail
Die Email wird auch versendet falls SkipSummaryWizard verwendet wird, daher habe ich auch einen Teil aus dem SummaryScripts nochmals in die Litetouch.wsf übernehmen müssen.
Konfiguriert wird das Emailsenden via customsettings.ini oder Task Sequenz Variablen.
In der customsettings.ini müssen Folgende Parameter gesetzt werden:
[Settings] Priority=Default Properties=SummaryEmailEnable, SummaryEmailFrom, SummaryEmailTo, SummaryEmailRelay, SummaryEmailRelayPort [Default] SummaryEmailEnable=YES SummaryEmailFrom=absendermail@domain.de SummaryEmailRelay=smtpserver.domain.de SummaryEmailRelayPort=25 SummaryEmailTo=empfaengermail@domain.de
TIPP: Im Betreff wird der _SMSTSPackageName verwendet, weswegen dieser zwecks der Schönheit pro Task sequenz gesetzt werden sollte.
Viel Spaß damit! 🙂
Grüße, Alex