I wanted an easy way to know if OS deployments were failing or succeeding. We’ve come up with a good way of sending an email outlining task sequence completion status.
- In SCCM, create a Status Filter rule by going to Site Database – Site Management – Primary Site – Site Settings – Status Filter Rules.
- On the general tab, use Component : Task Sequence Manager, Message ID: 11170 . (11170 signifies failure, 11171 is for success.)
- On the actions tab, tick Run a program and use something like ‘powershell.exe D:\SCRIPTS\TS_Email_Notification.PS1 %msgsys’.
TS_Email_Notification.PS1 should contain the following:
param([string]$strComputerName)
$erroractionpreference = "SilentlyContinue"
$strSMTP = "mail.domain.com"
$strSubject = "SCCM OSD Deployment Completed for $strComputerName"
$strBody = "$strComputerName has Completed the Task Sequence"
$MailMessage = New-Object System.Net.Mail.MailMessage
$MailMessage.IsBodyHtml = $true
$SMTPClient = New-Object System.Net.Mail.smtpClient
$SMTPClient.host = $strSMTP
$Sender = New-Object System.Net.Mail.MailAddress("sender@domain.com", "Sender")
$Recipient = New-Object System.Net.Mail.MailAddress("recipient@domain.com", "Recipient")
$MailMessage.Sender = $Sender
$MailMessage.From = $Sender
$MailMessage.Subject = $strSubject
$MailMessage.To.add($Recipient)
$MailMessage.Body = $strBody
$SMTPClient.Send($MailMessage)
You just need to adjust the above Powershell script for your mail settings and you will now receive an email each time there is a successful or failed OS deployment.
Possibly related posts (auto generated):
Related Articles
6 users responded in this post
i’ve set up a status alert like you said with the script but it doesn’t run it. I changed it to look for the message ID only 10008 for completed successfully.
I configured the script and ran the command line manually and it works. But after the job runs successfully it never runs the other program.
Is there anything I need to look at or if there’s a log I can view to see on why it didn’t run.
bizzarro, I was also having inconsistent resulting using the powershell script, so I’ve re-written it with VBScript and is as follows:
‘START VBS
Dim sComputerName
Set args = WScript.Arguments
sComputername = args.Item(0)
Set objMessage = CreateObject(“CDO.Message”)
objMessage.Subject = “SCCM OS deployment failed for ” & sComputername
objMessage.From = “sender@domain.com”
objMessage.To = “recepient@domain.com”
objMessage.TextBody = sComputername &” has failed a task sequence”
‘==This section provides the configuration information for the remote SMTP server.
‘==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2
‘Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = “mail.domain.com”
‘Server port (typically 25)
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25
objMessage.Configuration.Fields.Update
‘==End remote SMTP server configuration section==
objMessage.Send
‘ END VBS
The action for the status filter rule is “CSCRIPT.EXE D:\SCRIPTS\email.vbs %msgsys” with Message ID as “11170″ and Component as “Task Sequence Manager”
Actually the problem was that I can’t use it as a command line within the Actions tab. I put the command line into a .cmd file to run after the job is done. That works, but the %msgsys doesn’t seem to be working. It says “msgsys” rather than the computer name from what I read in the documentation on the command lines.
Thanks,
Harvey
Have you tried just using ‘CSCRIPT.EXE D:\SCRIPTS\email.vbs %msgsys’. I am sure this works. If you start using batch files you will lose the parameters that are being fed into the command.
Sorry, I was referring to your original Powershell script when I ran that command.
I just piece together one in VB from another code I found online, should of just came here instead to use yours. The only problem I have in my VBscript is that I can’t set the argument to the strComputer variable. It says object or method not supported Item. If I leave the argument as is and use that as the variable it works fine. For this case I only need one argument but wonder why other posted scripts work allow people to set the variable?
Thanks.
I have it working like your script and see where the error is in theirs. They reversed the objARgs.Item(0)= StrComputer instead of StrComputer = ojbArgs.Item(0) like you have it. That resolved that issues and now I have it working, thanks.
Harvey
Leave A Reply