#Import-Module "C:\MININT\Modules\Microsoft.BDD.TaskSequenceModule" #Import-Module "C:\MININT\Modules\ZTIUtility" Write-Progress -Activity "Sending email" -Status "Getting Information" -PercentComplete 25 -Id 1 $NewMsg = new-object Net.Mail.MailMessage $SMTP = new-object Net.Mail.SmtpClient($tsenv:OSDSendMailSMTPServer) Write-Progress -Activity "Sending email" -Status "Creating Email" -PercentComplete 50 -Id 1 $Get_Monitoring = Get_My_MonitoringData -path DSManager: | where {$_.name -eq $MyComputer} $Start = $Get_Monitoring.StartTime $End = $Get_Monitoring.EndTime $LastTime = $Get_Monitoring.LastTime $WarningNB = $Get_Monitoring.warnings $ErrorNB = $Get_Monitoring.Errors $step = $Get_Monitoring.StepName $Percentage = $Get_Monitoring.PercentComplete $step = $Get_Monitoring $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" } $NewMsg.IsBodyHTML = $true $NewMsg.From = "$tsenv:OSDSENDMAILFROM" $NewMsg.To.Add($tsenv:OSDSendMailToPri) $NewMsg.CC.Add($tsenv:OSDSendMailToSec) $NewMsg.Subject = "Notification from the OS Deployment solution" $NewMsg.Body = "

Bonjour,

Déploiement de Système d'Exploitation est fini avec succès sur l'ordinateur: $env:COMPUTERNAME - $(get-date)

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

Lycée: $NomLycee
Nom Ordinateur: $env:COMPUTERNAME
TaskSequenceName: $TSEnv:TASKSEQUENCENAME
Vendor: $TSEnv:Make
Model: $TSEnv:Model
Memory: $TSEnv:Memory Megabyte
SerialNumber: $TSEnv:SerialNumber
AssetTag: $TSEnv:AssetTag
Start time: $Start
End time: $End
Warning: $WarningNB
Error: $ErrorNB
Groupe WSUS: $TargetGroup
WUServer: $WUServer
WUStatusServer: $WUStatusServer
Serveur Kaspsersky: $KSC_IP
Antivirus Installé: $KSC_AV

Meilleures salutations.

" if ($tsenv:OSDSendMailIncludeBDDLog -eq "YES"){ $AttachToMail001 = new-object Net.Mail.Attachment($tsenv:LOGPATH + "\BDD.log") $NewMsg.Attachments.Add($AttachToMail001) } Write-Progress -Activity "Sending email" -Status "Sending email to $tsenv:OSDSendMailToPri" -PercentComplete 75 -Id 1 Start-Sleep 1 $NewMsg $SMTP.Send($NewMsg) if ($OSDSendMailIncludeBDDLog -eq "YES"){$AttachToMail.Dispose()} Write-Progress -Activity "Sending email" -Status "Done" -PercentComplete 100 -Id 1