When deploying an operating system with SCCM / MEMCM, monitoring your deployment is crucial. You can use reports in a more dynamic way. Imagine receiving an email saying “Hey your deployment is complete. The computer can be delivered to the client”. SCCM can send an email based on a specific status message generated by the site server. And this is exactly what will be done in this blog post.

SCCM records everything action in Status Messages. You are probably familiar with the tons server logs files but SCCM also records everything on the site server itself. A quick look at the Status message shows that there’s tons of available information.

Status Message

  • In the SCCM Console
  • Go to Monitoring / System Status / Status Message Queries / All Status Message
sccm osd send email
  • Status Message shows all actions, there’s lots of valuable information in there
sccm osd send email

Yeah great !… now what? Using the power of PowerShell, I tell SCCM to send an email each time an event is generated. With imagination, you can do pretty cool stuff in there

SCCM OSD Send Email – Status Filter Rules

We’ll use a Status filter rule to run our script.

It permits to do an action when a specific code is generated. In my example, I’ll use MessageID 11171 to run a Powershell script. MessageID 11171 means : Task Sequence completed

  • In the Configuration Manager Console
  • Open Administration / Sites / Status Filter Rules
  • In Status Filter Rules window, click Create
  • On the Create Status Filter Rule wizard, fill the following text boxes:
    • Name : Task Sequence email
    • Source : Client
    • Message ID : 11171
    • Property : Package ID
    • Property Value – PS10000A (change the value with your TS ID). You can find your task sequence PackageID in the console. Software Library / Operating Systems / Task Sequences
sccm osd send email
  • In the Action tab at the top
  • Check Run a program and enter the following program: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file D:\Scripts\OSD_Deployment_Success.ps1 -ComputerName %msgsys -TS “Windows 10 x64”
sccm osd send email

So we just told SCCM to run the PowerShell script when MessageID 11171 gets generated.

Here’s the Powershell script used for that :

Param($ComputerName,$TS)

$Subject = "$TS was successful on $ComputerName"

$Message = "$TS was successful on $ComputerName"

$From = "IT Administrator <[email protected]>"

$To = "IT Administrator <[email protected]>"

$SmtpServer = "your.smtp.server"

Send-MailMessage -Subject $Subject -Body $Message -From $From -To $To -SmtpServer $SmtpServer

Change the variable ($Subject,$Message,$From,$To,$SmtpServer) to fit your environment.

Bonus tip #1: Test the PowerShell script locally before running it and see with your Exchange Administrators to avoid this error “Send-MailMessage: Unable to connect to the remote server”.

Bonus tip #2: Error “File test.ps1 cannot be loaded because the execution of scripts is disabled on this system”.  This is because your Powershell execution policy is not configured correctly (hint: Get-ExecutionPolicy -list)

Bonus tip #3: If you’re using Unknown Computer collection and receiving MININT-XXXX name, refer to this article which explains it.

sccm osd send email

Comments (32)

Bailey Raimo

02.19.2020 AT 07:36 AM
I like your blog post. Keep on writing this type of great stuff. I make sure to follow up on your blog in the future. For instant support related to the Forgot AOL mail Password please visit http://www.emailscustomercare.com/forgot-aol-password/ for the best solution.

vedant

07.16.2019 AT 04:24 AM
Thank you so much for this site.

Seery Lazos

03.19.2019 AT 02:58 AM
Hello I thank full to you, because you are looking comments on this post and you are active on it I too appreciate you & System Center Dudes for all the great information, really i did learned so many new things before sometime i got the problem for Reset Roadrunner Password then i found the link http://www.roadrunnersupport247.com/reset-roadrunner-password/ it is very helpful

Robert

02.19.2019 AT 09:29 AM
Benoit, Hopefully, you're still seeing comments for this post! I too appreciate you & SCDudes for all the great info. One question on this post. We are using it and is wonderful. Our only issue is that UNKNOWN computers always say their MININT-xxxxxx name instead of the OSDComputerName (which we prompt for directly after PXE boot). The %msgsys give us the MININT-xxxxxx so is there any way to get the OSDComputerName into the email script?

Andy

09.25.2018 AT 10:59 AM
Did the guys that couldn't get this to send email when running the TS but it worked when running manually ever solve it ? I have the same issue

Muzaffer

08.02.2018 AT 06:46 AM
Bonjour Benoit, Thank you for the very useful article but I'm not sure if %msgsys works correctly on CM1710 which I'm using? It's not returning the actual computer name but MINT-XXXX. ps. After 3 years of this article, people currently discussing it on SCCM Reddit!

John Wasko

09.27.2017 AT 09:19 AM
Old Post but I am running into a couple of issues. The first is that %msgsys is pulling the temp computer name "MNINT..." and not the name that I am using as the collection variable or the name that is reported to SCCM in it's event log. The second is that the subject lines are not mailing what is between the quotes but garbling it with prepended question marks and only using the first word within the quotes "???Company" instead of "Company HP 745 win 7"

Jose Camacaro Latouche

08.31.2017 AT 01:42 PM
Awesome guide! Is it possible to use wild cards (%) in the "system" field when creating a status filter rule? i.e. If system name is "2017-%" will it only trigger the PS1 if the client's name start with '2017- '?

Jason

10.06.2015 AT 01:23 PM
Is it possible to include the computer model and serial number in this e-mail? I don't know if SCCM has captured the data yet. I know the S/N is stored in SMS_G_System_PC_BIOS.SerialNumber

Jose Garcia

01.28.2016 AT 01:02 PM
In the powershell script you can use get-wmiobject (gwmi) to collect that information ex: Get-WmiObject Win32_Computersystem -computername $ComputerName| Select-Object -expand Model Get-WmiObject Win32_bios -computername $ComputerName| Select-Object -expand SerialNumber

Tom

09.07.2017 AT 05:01 PM
Hello, I been trying to added the Get-WmiObject Win32_Computersystem in the script but I keep getting the results of the SCCM server in the email as opposed to the client machine information. Would appreciate if you can share any tips of how I can use this command to pull the client information instead of the SCCM server. Thanks

Derryn

09.28.2015 AT 10:58 AM
Is there a way I can run this for ANY task sequence? It would be awesome if there were some detail in the email as well. perhaps a link to the report with the field options already populated?

Benoit Lecours

09.30.2015 AT 07:31 AM

Don Lynch

09.23.2015 AT 10:10 AM
This works great however during my task sequence I use a HTA to name the computer by location and first 8 of the SN... but I notice in the status logs it is still showing up as a MINT-xxxxx name. Any suggestions to actually have this log the actual name of the machine so it emails the actual PC name?

Randy

11.08.2018 AT 02:25 PM
I made quite a few changes to get it to work this way. First, I added this script as part of my task sequence instead of as a status filter. Done this way, it runs locally on the machine instead of on the Site Server. I followed the instructions here to accomplish this: http://schadda.blogspot.com/2012/01/sccm-2012-how-to-catch-errors-in-task.html Then I used task sequence variables to fill the $ComputerName and $TS (%OSDComputerName% and %_SMSTSPackageName%) instead of passing them as parameters. Then I added a step, prior to running the script, to set OSDComputerName to %_smstsmachinename% if OSDComputerName doesn't already exist, and then use %OSDComputerName% instead of %_smstsmachinename% in all instances. With this setup. if OSDComputerName is set you should get that value. If it's not set, you'll get the MININT-xxxxx name. Plus it will work in any Task Sequence and will give you the name of the task sequence. I also added some of the other stuff that was talked about in that link (uploading the logs.) Then I made all of these steps into a child task sequence, and reference that child task sequence in my main task sequences.

JSG2006

02.23.2016 AT 05:59 PM
Same issue I'm having. I've attempted a couple of suggestions but I can't generate the true hostname consistently.

Dennis

07.05.2015 AT 02:55 PM
This is very cool! However, may I know what is the computer that executes the script (i.e. the computer that sends the email message). Is it the from site server or from the computer which the task sequence ran?

Benoit Lecours

07.06.2015 AT 10:08 AM
It's the site server computer account

Evgeniy

04.02.2015 AT 09:15 AM
This is worked with local install Exchange Server? i have error: Send-MailMessage : Cannot validate argument on parameter 'Subject'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command a gain. At line:2 char:27 + Send-MailMessage -Subject $Subject -Body $Message -From $From -To $To -SmtpServe ... + ~~~~~~~~ + CategoryInfo : InvalidData: (🙂 [Send-MailMessage], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.SendMailMessage

Benoit Lecours

04.07.2015 AT 07:58 AM
Yes it should work using a local Exchange server. Can you post your script ?

Florian

03.26.2015 AT 02:33 AM
Hello, I tested it and ist working. I saw you are catching the computer Name by using %msgsys. I use the script to catch Errors and i want to catch the discription. Do you know who to do that?

Benoit Lecours

03.27.2015 AT 06:48 AM
Sure, you can use %msgdesc for this. In fact you can use any parameters listed : https://technet.microsoft.com/en-us/library/bb693758.aspx

Peter

02.10.2015 AT 02:42 PM
Hmm, I'm not actually getting the emails. Powershell policy is unrestricted. If I run the script manually then I get the email...!?

Benoit Lecours

02.10.2015 AT 03:01 PM
Have you tried running the script under the SYSTEM account using psexec ?

Kieran

03.11.2015 AT 10:54 PM
Hi Benoit, I'm experiencing the same thing as Peter. I cannot receive the email from the event. I can manually run the command it sends the email. If I run under PSEXEC as system is works. (although to get this to work I had to add permissions for my SCCM server to send as myself (and then set the script to send as myself)) for this to work. any ideas? cheers, Kieran

Derryn

09.30.2015 AT 09:47 AM
I have the same issue as well. I used PS exec to run as system and I get the email. But I'm not getting the email when the TS runs. I checked the box to write to the event log so I can see the event log that the correct status message is used. The policy is unrestricted, in my troubleshooting I also added -ExecutionPolicy Bypass still no emails. I'm running SCCM 2012 R2 SP1

Benoit Lecours

09.30.2015 AT 10:36 AM
Have you done all required tasks ? Dcom permission and security rights ?

Martin

01.28.2015 AT 05:41 PM
That's awesome! A really great find. Quick question though, is there more field than the Computer name that can be passed in the script, so the email would contain the description and details from message? If so, how the variables are named? Would be really useful for message ID 11171 for task sequence failure. Really useful site by the way guys! Keep up the great work!

Benoit Lecours

01.28.2015 AT 07:49 PM
Salut Martin ! Sure, there's a whole bunch of other parameters you could add. Check this link for the full list. Be sure to create an input parameters in the Powershell script and add the extra parameter in the Run a program filed of the Status Filter Rule. Thanks for the kind words about the blog 😉