Skip to content

Scripts, tools and tips, mostly around Microsoft SCCM and EMS

smsagent

  • About
  • Books / Guides
    • Deploying Custom Microsoft Office Templates with System Center Configuration Manager
    • Managing Java with Configuration Manager and PowerShell
  • Free ConfigMgr Reports
    • Instructions
    • Client Health Summary Report
    • Client Health Report
  • POSH 5 Custom Classes
    • Creating a Custom Class Library
    • Power Ping
    • Background Job
    • SQL Query
  • Tools
    • ConfigMgr Add2Collection
    • ConfigMgr Client Notification
    • ConfigMgr Deployment Reporter
    • ConfigMgr PXE Boot Log
    • ConfigMgr Remote Compliance
    • ConfigMgr Task Sequence Monitor
    • Reliability Viewer for Windows
    • System Explorer for Windows
    • WPF Control Explorer

Tag: PowerShell SQL email

PowerShell Template for HTML-Style Email Report with SQL Data

April 5, 2018 by Trevor Jones, posted in ConfigMgr, Powershell, Reporting, SCCM, SQL

Long time since I wrote a blog – been uber busy – but found time to slip this one in! Working with ConfigMgr a lot I have a number of html-style email reports written in PowerShell that get data from the SCCM database and send it to me and other SCCM admins. Personally, I much prefer getting a regular email containing useful information than to use the canned SSRS reports, or checking the SCCM console.

Below is a template script that can be used to send regular reports containing SQL data with a simple SQL query as an example. Simply create a scheduled task on an admin server to run the report regularly, using an action like:

PowerShell.exe -ExecutionPolicy Bypass -WindowStyle Hidden – File MyScript.ps1

The email from this example looks like:

htmlemail

The script uses a custom html style and a publically available cssĀ file to provide the formatting (this does mean internet access is required).

To use the script, you need the relevant permissions to query your SQL database and enter the SQL details at the top of the script, as well as your email parameters. Add your SQL query, update the headers in the ConvertTo-Html cmdlet and you’re away.

Ciao for now!

Tagged ConfigMgr SQL report, powershell html email, PowerShell SQL email, SCCM SQL report2 Comments

Latest Free Tool: Delivery Optimization Monitor

Recent Posts

  • Create Collections for SCCM Client Installation Failures by Error Code
  • Monitoring Changes to Active Directory Sites and Subnets with PowerShell
  • New Tool: Delivery Optimization Monitor
  • Creating ADR Deployments in SCCM with PowerShell
  • Monitor Content Downloads Between an SCCM Distribution Point and a Client
  • New Tool: ConfigMgr Client Notification
  • Querying for Devices in Azure AD and Intune with PowerShell and Microsoft Graph
  • Intune Client-Side Logs in Windows 10
  • Create a Custom Splash Screen for a Windows 10 In-Place Upgrade
  • Create Disk Usage Reports with PowerShell and WizTree

Top Posts & Pages

  • Create Collections for SCCM Client Installation Failures by Error Code
    Create Collections for SCCM Client Installation Failures by Error Code
  • A Customisable WPF MessageBox for PowerShell
    A Customisable WPF MessageBox for PowerShell
  • Find the Full Windows Build Number with PowerShell
    Find the Full Windows Build Number with PowerShell
  • Improving the User Experience in a ConfigMgr OS Upgrade Task Sequence
    Improving the User Experience in a ConfigMgr OS Upgrade Task Sequence
  • Create a Custom Splash Screen for a Windows 10 In-Place Upgrade
    Create a Custom Splash Screen for a Windows 10 In-Place Upgrade
  • ConfigMgr Task Sequence Monitor
    ConfigMgr Task Sequence Monitor
  • Client Health Report
    Client Health Report
  • Using Windows 10 Toast Notifications with ConfigMgr Application Deployments
    Using Windows 10 Toast Notifications with ConfigMgr Application Deployments
  • Add Custom Notifications to a ConfigMgr Task Sequence
    Add Custom Notifications to a ConfigMgr Task Sequence
  • Prompting for Input During a Task Sequence
    Prompting for Input During a Task Sequence

Category Cloud

Active Directory Applications Azure Compliance ConfigMgr configmgr client health Drivers Intune MDT Microsoft Office Network Orchestrator OS Deployment Packages Powershell Project Server PXE Boot Reporting SCCM Software Updates SQL Uncategorized VMWare Windows Server Windows Troubleshooting WPF WSUS

Recent Comments

Esben S. Nielsen on A Customisable WPF MessageBox…
Dean Huddleston on Free ConfigMgr Task Sequence M…
Steve on Create a Custom Splash Screen…
Silvester on New Tool: ConfigMgr Client…
SCCM_Admin on Create a Custom Splash Screen…

Archives

  • February 2019
  • January 2019
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • November 2016
  • September 2016
  • August 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014

Blog Stats

  • 429,781 hits

Categories

  • Active Directory
  • Applications
  • Azure
  • Compliance
  • ConfigMgr
  • configmgr client health
  • Drivers
  • Intune
  • MDT
  • Microsoft Office
  • Network
  • Orchestrator
  • OS Deployment
  • Packages
  • Powershell
  • Project Server
  • PXE Boot
  • Reporting
  • SCCM
  • Software Updates
  • SQL
  • Uncategorized
  • VMWare
  • Windows Server
  • Windows Troubleshooting
  • WPF
  • WSUS

Follow me on Twitter

My Tweets

Meta

  • Register
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.com

Enter your email address to follow this blog and receive notifications of new posts by email.

Follow smsagent on WordPress.com
Blog at WordPress.com.
Cancel