Skip to main content

Get New SQL Updates

Summary

Audits and reports on new SQL-related Windows Updates available for installation since the last execution. On its first run, the script retrieves updates released within the past 90 days. Detection uses the native Windows Update API and falls back to the PSWindowsUpdate module only when the API scan fails or returns no results.

The script also manages the ConnectWise ticket lifecycle by firing webhooks to the CWRMM Ticket Management for Monitors workflow:

  • Ticket created: When one or more SQL updates released after the last successful run are detected on the machine.
  • Ticket closed: When no SQL updates remain available for installation on the machine (all previously reported updates have been installed).
  • No action: When SQL updates are still available but were already reported on a previous run (no new releases since the last run).

Because a Create webhook fires on every run that detects newly released updates, a machine can have multiple open tickets when patches are released on different days. For example, a patch released and detected today opens a ticket; a second patch released tomorrow and detected on the next run opens another ticket while the first one remains open.

If neither detection method completes, the scan is treated as an unknown state rather than a clean machine: the script fails without triggering a webhook and without advancing the last run date, so pending updates remain eligible for reporting on the next run.

Note: Script requires PowerShell 5+.

Sample Run

Image1

Dependencies

Task Setup Path

Tasks Path: AUTOMATIONTasks
Task Type: Script Editor

Task Creation

Description

  • Name: Get New SQL Updates
  • Description: Audits and reports on new SQL-related Windows Updates since the last script run.
  • Category: Patching

Image2

Script Editor

Step 1: Row -> Set Pre-defined Variable ( @workflowWebhookUrl@ = Ticket_Mgmt_Webhook_Url )

  • Variable Name: workflowWebhookUrl
  • Custom Field: Ticket_Mgmt_Webhook_Url
  • Operating System: Windows
  • Continue on Failure: False
  • PowerShell Script Editor:

Image5

Step 2: Row -> PowerShell script

  • Use Generative AI Assist for script creation: False
  • Expected time of script execution in seconds: 900
  • Operating System: Windows
  • Continue on Failure: False
  • PowerShell Script Editor:

PowerShell Script

Image3

Step 3: Row -> Script Log

  • Script Log Message: %Output%
  • Continue on Failure: False
  • Operating System: Windows

Image4

Completed Script

Image8

Output

  • Script Log
  • Ticket

Ticketing

Subject: SQL Updates pending review for <Computer Name> at <Client Name>
Ticket Body: <Output of the ticket body> Ticket Body Example:

1 new SQL Update(s) detected since 2025-05-15 07:41:50.

Detected Updates:


KB : KB5063757
Title : Security Update for SQL Server 2019 RTM CU (KB5063757)
Description : Security issues have been identified in the SQL Server 2019 RTM CU that could allow an attacker to
compromise your system and gain control over it. You can help protect your computer by installing this
update from Microsoft. After you install this item, you may have to restart your computer.
ReleaseDate : 8/12/2025 12:00:00 AM
IsMandatory : False
MsrcSeverity : Important

Schedule Task

Task Details

  • Name: Get New SQL Updates
  • Description: Audits and reports on new SQL-related Windows Updates since the last script run.
  • Category: Patching

Image9

Schedule

  • Schedule Type: Schedule
  • Timezone: Local Machine Time
  • Start: <Current Date>
  • Trigger: Time At <Current Time>
  • Recurrence: Every day

Image10

Targeted Resource

Device Group: SQL Servers

Image11

Completed Scheduled Task

Image12

Changelog

2026-08-12

  • Updated the script to use the ConnectWise workflow webhook for ticketing instead of the task's built-in ticketing function.
  • Switched primary update detection to the native Windows Update API; the PSWindowsUpdate module is now installed and imported only as a fallback when the API scan fails or returns no updates.

2025-08-13

  • Initial version of the document