This PowerShell script tracks and reports Microsoft Security Response Center (MSRC) updates for specific Knowledge Base (KB) articles, managing critical security information in a Notion database. It automatically clears old records, queries current KB severities, and updates Notion with severity details.
- Track KBs: Specify target KBs for monitoring or query all unique KBs for the specified report date.
- Notion Integration: Add KB severities to a Notion database automatically.
- Severity Levels: Supports Critical, Important, Moderate, and Low severity levels.
- Caching: Caches results to avoid repetitive API calls.
- Cross-Platform Paths: Detects OS and sets paths for caching and file storage.
- PowerShell 5.1+: Ensure PowerShell is installed.
- MSRCSecurityUpdates Module: The script uses
Get-MsrcCvrfDocument
for querying KB information. - Notion Integration: Set up a Notion integration token and database ID.
Variable | Description |
---|---|
$Global:TargetKBs |
Array of KB numbers to track, e.g., ("KB5041585", "KB5040442") . |
$Global:QueryAllUniqueKBs |
Set to $true to automatically query and track all unique KBs from the current report. |
$Global:ForceUpdate |
Set to $true to force data refresh from MSRC instead of using cached data. |
$Global:ShowCachedResults |
Set to $true to display cached results without querying MSRC. |
$Global:ReportDate |
Specifies the report date, formatted as yyyy-MMM (e.g., 2024-Nov ). |
$Global:NotionSecret |
Your Notion API secret token. |
$Global:NotionDatabaseId |
Notion database ID to store KB data. |
- Windows:
C:\temp\SecurityUpdateCache_{ReportDate}.json
- Linux/macOS:
/tmp/SecurityUpdateCache_{ReportDate}.json
- Add-ToNotion: Adds KB and severity data to Notion.
- Clear-NotionDatabase: Clears all records from the specified Notion database.
- Query-KBSeverity: Main function that:
- Clears Notion records.
- Queries cached results or updates from MSRC.
- Adds KBs and severities to Notion based on
TargetKBs
or all unique KBs.
- Extract-UniqueKBs: Extracts all KBs from report data and saves unique values to a file.
-
Install MSRCSecurityUpdates:
Install-Module -Name MSRCSecurityUpdates -Force
-
Configure Notion API:
- Set
Global:NotionSecret
with your Notion API key. - Set
Global:NotionDatabaseId
with your Notion database ID.
- Set
-
Run the Script:
.\security-updates.ps1
$Global:TargetKBs = @("KB5041585", "KB5040442")
$Global:ForceUpdate = $true
Query-KBSeverity
Sample output:
KB5041585 - Critical
KB5040442 - Important
Successfully added KB5041585 with severity Critical to Notion
Successfully added KB5040442 with severity Important to Notion
Logs errors if:
- The MSRC query fails.
- Notion API calls fail (e.g., due to incorrect permissions or token).
MIT License