Email Notification Script for SCCM Web Reports. I am interested in getting customized email notifications for the SCCM web reports. Below is the simple script we can use to get email alerts at regular intervals.
We can use Notification Email Scripts to print Notification message content from a server-side script. They are application files created in the main ServiceNow browser window and not in Studio.
You must create a scheduled task to run this script if you need the SCCM report’s output regularly or at a specific interval. Email Notification Script for SCCM.
Make necessary changes as per the environment and try this in the LAB environment before implementing this on Production.
Index |
---|
Email Notification Script for SCCM |
Email Notification Script for SCCM
The following is a sample Email Notification Script for SCCM to enable email notifications. We recommend trying this script in a preproduction environment and then deploying it to production.
Set WshShell = WScript.CreateObject(“WScript.Shell”)
Set objStream = Createobject(“ADODB.Stream”)
Set xmlhttp = CreateObject(“Microsoft.XmlHttp”)
url=”ENTER THE URL OF THE REPORT”
htmlReport=”EXACT PATH WHERE YOU NEED TO STORE THE HTML REPORT”
xmlhttp.open “Post”, url, False
xmlhttp.setRequestHeader “Content-Type”, “application/x-www-form-urlencoded”
xmlhttp.send “print=yes”
objStream.type = 1
objStream.open
objStream.Write xmlhttp.responseBody
objStream.savetofile htmlReport, 2
objStream.Close
Set objMessage = CreateObject(“CDO.Message”)
objMessage.Subject = “Sites by hierarchy with time of last site status update”
objMessage.From = “[email protected]”
objMessage.To = “PUT THE EMAIL ADDRESS OF THE RECEIPT”
‘objMessage.Cc = “<>”
objMessage.CreateMHTMLBody “EXACT PATH WHERE YOU NEED TO STORE THE HTML REPORT”
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”) = “SMTP SERVER NAME”
‘Server port (typically 25)
objMessage.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25
objMessage.Configuration.Fields.Update
objMessage.Send
Set objMessage=Nothing
Set WshShell = Nothing
Set xmlHttp= Nothing
WScript.Echo “Script Execution Finished”
We are on WhatsApp. To get the latest step-by-step guides and news updates, Join our Channel. Click here –HTMD WhatsApp.
Author
Anoop C Nair is Microsoft MVP! He is a Device Management Admin with more than 20 years of experience (calculation done in 2021) in IT. He is a Blogger, Speaker, and Local User Group HTMD Community leader. His primary focus is Device Management technologies like SCCM 2012, Current Branch, and Intune. He writes about ConfigMgr, Windows 11, Windows 10, Azure AD, Microsoft Intune, Windows 365, AVD, etc.