Did you know that SCCM can take an action when a specific message is generated on the site server?
SCCM records everything it does. You are probably familiar with the tons of logs files but SCCM also record everything on the site server itself.
A quick look to the Status message shows that there’s tons of available information.
Monitoring / System Status / Status Message Queries / All Status Message :
As you can see, there’s lots of valuable information in there.
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
How to do that ? 1 simple word ! “Status….filter….rules”… ok ! 3 words.
It permits to do an action when a specific code is generated. In my example, I’ll use MessageID 11171 to generate a powershell. (11171 = Task Sequence completed)
- Configuration Manager Console, open Administration workspace
- Select Sites
- Select Status Filter Rules
- In Status Filter Rules window, press Create
- On the Create Status Filter Rule wizard , you need to fill the following text boxes:
- Name – “Task Sequence email“
- Source – Client
- Message ID – 11171
- Property – Package ID
- Property Value – PS10000A (*****change that with your TS ID*****)
In the Action tab :
- Run a program : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file D:\Scripts\OSD_Deployment_Success.ps1 -ComputerName %msgsys -TS “Windows 7 x64”
So we jsut told SCCM to run the powershell script when MessageID 11171 gets generated. How cool is that?
Here’s the Powershell script used for that :
$Subject = “$TS was successful on $ComputerName”
$Message = “$TS was successful on $ComputerName”
$From = “IT Administrator <firstname.lastname@example.org>”
$To = “IT Administrator <email@example.com>”
$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 if you gets 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)
sccm osd send email
Founder of System Center Dudes. Based in Montreal, Canada, Senior Microsoft SCCM Consultant, 5 times Enterprise Mobility MVP. Working in the industry since 1999. His specialization is designing, deploying and configuring SCCM, mass deployment of Windows operating systems, Office 365 and Intunes deployments.