$Mail_SMTP = New-Object Net.Mail.SmtpClient($tsenv:OSDSendMailSMTPServer) $InfosEtab = Get-InfosEtab $NomLycee = $InfosEtab.NomLycee #On récupčre les infos WSUS sur le client $Key = "HKLM:\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate" $TargetGroup = Get-ItemPropertyValue $Key -Name "TargetGroup" $WUServer = Get-ItemPropertyValue $Key -Name "WUServer" $WUStatusServer = Get-ItemPropertyValue $Key -Name "WUStatusServer" #On récupčre les infos Kaspsersky sur le client $Key_KSC = "HKLM:\SOFTWARE\Wow6432Node\KasperskyLab\Components\34\1103\1.0.0.0\Statistics\AVState" $KSC_IP = Get-ItemPropertyValue $Key_KSC -Name "Protection_AdmServer" $KSC_AV = Get-ItemPropertyValue $Key_KSC -Name "Protection_AvInstalled" if ( $KSC_AV = "1" ) { $KSC_AV = "Oui" } Else { $KSC_AV = "Non" } $Mail_From = "$tsenv:OSDSENDMAILFROM" $Mail_To = "$tsenv:OSDSendMailToPri" $Mail_CC = "$tsenv:OSDSendMailToSec" $MyData = Get_My_MonitoringData | Select Date, "Computer Name", DeployID, "Percent Complete", PercentNumber, "Step Name", Warnings, Errors, "Start time", "End Time", "Ellapsed time", DeployStatus $Deployment_Date = $MyData.Date $Deployment_ComputerName = $MyData."Computer name" $Deployment_Status = $MyData.DeployStatus $Deployment_LastTime = $MyData.LastTime $Deployment_StepName = $MyData."Step Name" $Deployment_Warnings = $MyData.Warnings $Deployment_Errors = $MyData.Errors $Deployment_Percent_Complete = $MyData."Percent Complete" $Deployment_Start_time = $MyData."Start time" $Deployment_End_time = $MyData."End Time" $Deployment_Ellapsedtime = $MyData."Ellapsed time" # COPIER LE SCRIPT DE NOTIFICATION ICI # SCRIPT DE NOTIFICATION MAIL If ($tsenv:OSDSendMailIncludeBDDLog -eq "YES") { $AttachToMail001 = new-object Net.Mail.Attachment($tsenv:LOGPATH + "\BDD.log") #$NewMsg.Attachments.Add($AttachToMail001) } If ($Deployment_Status -eq 4) # deployment unresponsive { $Body = "

Bonjour,

Déploiement de Système d'Exploitation ne réponds pas depuis l'ordinateur: $Deployment_ComputerName - $(get-date)

Voir ci-dessous quelques informations sur votre déploiement :

Lycée: $NomLycee
Computer name: $Deployment_ComputerName
TaskSequenceName: $TSEnv:TASKSEQUENCENAME
Vendor: $TSEnv:Make
Model: $TSEnv:Model
Lenovo Model: $TSEnv:LenovoModel
Memory: $TSEnv:Memory Megabyte
SerialNumber: $TSEnv:SerialNumber
AssetTag: $TSEnv:AssetTag
Start time: $Deployment_Start_time
Last time: $Deployment_LastTime
Warning: $Deployment_Warnings
Error: $Deployment_Errors
Step name: $Deployment_StepName
Percent: $Deployment_Percent_Complete
Groupe WSUS: $TargetGroup
WUServer: $WUServer
WUStatusServer: $WUStatusServer
Serveur Kaspsersky: $KSC_IP
Antivirus Installé: $KSC_AV

Meilleures salutations.

" send-mailmessage -from "$Mail_From" -to "$Mail_To" -cc "$Mail_CC" -subject "MDT Monitoring status: Unresponsive - On $Deployment_ComputerName" -body $Body -BodyAsHtml -priority Normal -Attachments "$AttachToMail001" -smtpServer $Mail_SMTP break } ElseIf ($Deployment_Status -eq 3) # Deployment success { $Body = "

Bonjour,

Déploiement de Système d'Exploitation completed successfully on the computer: $Deployment_ComputerName - $(get-date)

Voir ci-dessous quelques informations sur votre déploiement :

Lycée: $NomLycee
Computer name: $Deployment_ComputerName
TaskSequenceName: $TSEnv:TASKSEQUENCENAME
Vendor: $TSEnv:Make
Model: $TSEnv:Model
Lenovo Model: $TSEnv:LenovoModel
Memory: $TSEnv:Memory Megabyte
SerialNumber: $TSEnv:SerialNumber
AssetTag: $TSEnv:AssetTag
Start time: $Deployment_Start_time
End time: $Deployment_End_time
Elapsed time: $Deployment_Ellapsedtime
Warning: $Deployment_Warnings
Error: $Deployment_Errors
Groupe WSUS: $TargetGroup
WUServer: $WUServer
WUStatusServer: $WUStatusServer
Serveur Kaspsersky: $KSC_IP
Antivirus Installé: $KSC_AV

Meilleures salutations.

" send-mailmessage -from "$Mail_From" -to "$Mail_To" -cc "$Mail_CC" -subject "MDT Monitoring status: Success - On $Deployment_ComputerName" -body $Body -BodyAsHtml -priority Normal -Attachments "$AttachToMail001" -smtpServer $Mail_SMTP break } ElseIf ($Deployment_Status -eq 2) # Deployment failed { $Body = "

Bonjour,

Déploiement de Système d'Exploitation failed on the computer: $Deployment_ComputerName - $(get-date)

Voir ci-dessous quelques informations sur votre déploiement :

Lycée: $NomLycee
Computer name: $Deployment_ComputerName
TaskSequenceName: $TSEnv:TASKSEQUENCENAME
Vendor: $TSEnv:Make
Model: $TSEnv:Model
Lenovo Model: $TSEnv:LenovoModel
Memory: $TSEnv:Memory Megabyte
SerialNumber: $TSEnv:SerialNumber
AssetTag: $TSEnv:AssetTag
Start time: $Deployment_Start_time
Last time: $Deployment_End_time
Warning: $Deployment_Warnings
Error: $Deployment_Errors
Step name: $Deployment_StepName
Percent: $Deployment_Percent_Complete
Groupe WSUS: $TargetGroup
WUServer: $WUServer
WUStatusServer: $WUStatusServer
Serveur Kaspsersky: $KSC_IP
Antivirus Installé: $KSC_AV

Meilleures salutations.

" send-mailmessage -from "$Mail_From" -to "$Mail_To" -Cc "$Mail_CC" -subject "MDT Monitoring status: Failed - On $Deployment_ComputerName" -body $Body -BodyAsHtml -priority Normal -Attachments "$AttachToMail001" -smtpServer $Mail_SMTP break } write-host "Deployment finished"