Skip to content

Send Email after OSD Tasks

Featured Replies

I've tried the instructions here with no success (there's no Task Sequence Manager component) and I tried taking the VBScript and adding it as a "run command prompt" task to the end of a OSD Task.

 

What's the best way to have an email sent out after a deployment is successful (like MDT 2010 can do)

  • Author

I don't know if this will help anyone, but here's something I threw together after scouring the googles...

 

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set objAdsSystemInfo = CreateObject("adsysteminfo")

Set objComputername = Getobject("LDAP://" & objAdsSystemInfo.ComputerName)

Set colServiceList = objWMIService.ExecQuery _

("Select * from Win32_Service where Name = 'PortBlock Service'")

 

strHostName = UCase(replace(objComputerName.Name,"CN=",""))

 

For Each objService in colServiceList

If objService.State = "Running" Then

objService.StopService()

Wscript.Sleep 5000

End If

errReturnCode = objService.ChangeStartMode("Automatic")

Next

 

Set objMessage = CreateObject("CDO.Message")

 

objMessage.Subject = "SCCM OS deployment has completed" & " " & strHostName

objMessage.From = "SCCM_Server@domain.com"

objMessage.To = "my_email@domain.com"

objMessage.TextBody = "This attachement Contains the Parsed log files" & vbcrlf & "Please review its contents"

objMessage.AddAttachment "c:\windows\system32\ccm\logs\smsts.log"

objMessage.Configuration.Fields.Item _

("
) = 2

objMessage.Configuration.Fields.Item _

("
) = _

"smtp.domain.com"

objMessage.Configuration.Fields.Item _

("
) = 25

objMessage.Configuration.Fields.Update

objMessage.Send

 

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

 

Set colServiceList = objWMIService.ExecQuery _

("Select * from Win32_Service where Name = 'PortBlock Service'")

 

For Each objService in colServiceList

If objService.State = "Stopped" Then

objService.StartService()

Wscript.Sleep 5000

End If

errReturnCode = objService.ChangeStartMode("Automatic")

Next

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.