Email Notification Script for SCCM Web Reports. I want to get customized eMail notifications for the SCCM web reports, which I am interested in. Below is the simple script we can use to get eMail alerts in regular intervals.
Note ==> Need to create a scheduled task to run this script if you need the output of the SCCM report regularly or in a specific interval.
SCCM ADR Failure Alerts Setup Using ConfigMgr Subscriptions | ConfigMgr HTMD Blog (anoopcnair.com)
<Make necessary changes as per environment and try this in LAB environment before implementing this on 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”
Anoop is Microsoft MVP! He is a Solution Architect in enterprise client management 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 main focus is on Device Management technologies like SCCM 2012, Current Branch, and Intune. E writes about ConfigMgr, Windows 11, Windows 10, Azure AD, Microsoft Intune, Windows 365, AVD, etc…