Enhanced Drive Space Monitoring Configuration Writer
Summary
The Enhanced Drive Space Monitoring Configuration Writer is a preparation task that builds the local monitoring configuration used by the Enhanced Drive Space Monitoring monitor set. It does not perform any drive space monitoring itself. Instead, it reads the threshold values you define in ConnectWise RMM custom fields and writes a structured JSON file that the monitor set reads every time it runs.
How it works
-
Custom Fields Evaluation
The script reads drive space thresholds (per capacity bucket) and drive inclusion/exclusion lists from custom fields at the Company, Site, and Endpoint levels. It follows a strict priority order: Endpoint → Site → Company. If a value is set at the Endpoint level, that value is used. If not, the Site level is checked, then the Company level. If no value is set at any level, sensible defaults are applied. -
Server & Workstation Separation
The script automatically detects whether the endpoint is a Windows Server or Workstation and applies the correct set of Company/Site fields (_Svror_Wkssuffix). This allows you to set different thresholds for servers and workstations without duplicating scripts. -
Configuration File Generation
Once the final values are resolved, the script writes a JSON configuration file to the endpoint:C:\ProgramData\_Automation\Script\EnhancedDriveSpaceMonitoring\EnhancedDriveSpaceMonitoring.jsonThe file contains:
- Thresholds – an array of capacity buckets (16–300 GB, 300–1024 GB, 1024–4096 GB, 4096+ GB), each with a numeric value and unit (% , MB, or GB).
- IncludeDrives – a string specifying which drive letters to monitor (
All,None, or a string likeCDEF). - ExcludeDrives – a string specifying which drive letters to ignore (
None,All, or letters likeZ).
Sample Scenario 1: Using Default Values
No custom fields are configured at any level. The script runs on a server and uses the built‑in defaults: 10% for 16–300 GB drives, 30 GB for 300–1024 GB drives, 50 GB for 1024–4096 GB drives, 100 GB for 4096+ GB drives, include all drives, exclude none.
The resulting configuration file would be:
{
"Thresholds": [
{ "Bucket": "16To300", "Value": 10, "Unit": "Percent" },
{ "Bucket": "300To1024", "Value": 30, "Unit": "GB" },
{ "Bucket": "1024To4096", "Value": 50, "Unit": "GB" },
{ "Bucket": "4096Plus", "Value": 100, "Unit": "GB" }
],
"IncludeDrives": "All",
"ExcludeDrives": "None"
}
Sample Scenario 2: Using Custom Field Overrides
An administrator wants to monitor only the C and D drives on a critical server with tighter limits. At the Endpoint level, they set:
EDSM_16To300Threshold=5%EDSM_300To1024Threshold=20GBEDSM_DrivesToInclude=CDEDSM_DrivesToExclude=None
The configuration file becomes:
{
"Thresholds": [
{ "Bucket": "16To300", "Value": 5, "Unit": "Percent" },
{ "Bucket": "300To1024", "Value": 20, "Unit": "GB" },
{ "Bucket": "1024To4096", "Value": 50, "Unit": "GB" },
{ "Bucket": "4096Plus", "Value": 100, "Unit": "GB" }
],
"IncludeDrives": "CD",
"ExcludeDrives": "None"
}
Ticketing & Alerting Behavior
- A separate Enhanced Drive Space Monitoring monitor set reads the configuration file and periodically checks the drive space.
- Alerts and tickets are generated by the monitor set when a drive falls below its assigned threshold.
- The configuration file is updated once per day (or manually) by this task, so any changes to custom fields take effect on the next scheduled run.
Sample Run

Dependencies
- Custom Field: EDSM_16To300Threshold_Svr
- Custom Field: EDSM_16To300Threshold_Wks
- Custom Field: EDSM_16To300Threshold_Svr
- Custom Field: EDSM_16To300Threshold_Wks
- Custom Field: EDSM_16To300Threshold
- Custom Field: EDSM_300To1024Threshold_Svr
- Custom Field: EDSM_300To1024Threshold_Wks
- Custom Field: EDSM_300To1024Threshold_Svr
- Custom Field: EDSM_300To1024Threshold_Wks
- Custom Field: EDSM_300To1024Threshold
- Custom Field: EDSM_1024To4096Threshold_Svr
- Custom Field: EDSM_1024To4096Threshold_Wks
- Custom Field: EDSM_1024To4096Threshold_Svr
- Custom Field: EDSM_1024To4096Threshold_Wks
- Custom Field: EDSM_1024To4096Threshold
- Custom Field: EDSM_4096PlusThreshold_Svr
- Custom Field: EDSM_4096PlusThreshold_Wks
- Custom Field: EDSM_4096PlusThreshold_Svr
- Custom Field: EDSM_4096PlusThreshold_Wks
- Custom Field: EDSM_4096PlusThreshold
- Custom Field: EDSM_DrivesToInclude_Svr
- Custom Field: EDSM_DrivesToInclude_Wks
- Custom Field: EDSM_DrivesToInclude_Svr
- Custom Field: EDSM_DrivesToInclude_Wks
- Custom Field: EDSM_DrivesToInclude
- Custom Field: EDSM_DrivesToExclude_Svr
- Custom Field: EDSM_DrivesToExclude_Wks
- Custom Field: EDSM_DrivesToExclude_Svr
- Custom Field: EDSM_DrivesToExclude_Wks
- Custom Field: EDSM_DrivesToExclude
- Group: Enhanced Drive Space Monitoring
- Solution: Enhanced Drive Space Monitoring
Custom Fields
| Name | Example | Level | Type | Default Value | Description |
|---|---|---|---|---|---|
| EDSM_16To300Threshold_Svr | 10%, 500MB, 0, 15GB | Company | Text Box | 10% | Defines Company baseline limit for 16-300 GB drives on Servers. Overridden if Site or Endpoint limit exists. Enter X%, XMB, or XGB (e.g., 10%, 500MB). Set to 0 to disable. Name must match across levels. |
| EDSM_16To300Threshold_Wks | 10%, 500MB, 0, 15GB | Company | Text Box | 10% | Defines Company baseline limit for 16-300 GB drives on Workstations. Overridden if Site or Endpoint limit exists. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. |
| EDSM_16To300Threshold_Svr | 10%, 500MB, 0, 15GB | Site | Text Box | Defines Site-level limit for 16-300 GB drives on Servers. Overrides Company level, but overridden by Endpoint. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. | |
| EDSM_16To300Threshold_Wks | 10%, 500MB, 0, 15GB | Site | Text Box | Defines Site-level limit for 16-300 GB drives on Workstations. Overrides Company level, but overridden by Endpoint. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. | |
| EDSM_16To300Threshold | 10%, 500MB, 0, 15GB | Endpoint | Text Box | Defines Endpoint-level limit for 16-300 GB drives. Overrides any Site or Company level setting. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. | |
| EDSM_300To1024Threshold_Svr | 10%, 500MB, 0, 15GB | Company | Text Box | 30GB | Defines Company baseline limit for 300-1024 GB drives on Servers. Overridden if Site or Endpoint limit exists. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. |
| EDSM_300To1024Threshold_Wks | 10%, 5000MB, 0, 55GB | Company | Text Box | 30GB | Defines Company baseline limit for 300-1024 GB drives on Workstations. Overridden if Site or Endpoint limit exists. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. |
| EDSM_300To1024Threshold_Svr | 10%, 5000MB, 0, 55GB | Site | Text Box | Defines Site-level limit for 300-1024 GB drives on Servers. Overrides Company level, but overridden by Endpoint. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. | |
| EDSM_300To1024Threshold_Wks | 10%, 5000MB, 0, 55GB | Site | Text Box | Defines Site-level limit for 300-1024 GB drives on Workstations. Overrides Company level, but overridden by Endpoint. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. | |
| EDSM_300To1024Threshold | 10%, 5000MB, 0, 55GB | Endpoint | Text Box | Defines Endpoint-level limit for 300-1024 GB drives. Overrides any Site or Company level setting. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. | |
| EDSM_1024To4096Threshold_Svr | 10%, 50000MB, 0, 150GB | Company | Text Box | 50GB | Defines Company baseline limit for 1024-4096 GB drives on Servers. Overridden if Site or Endpoint limit exists. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. |
| EDSM_1024To4096Threshold_Wks | 10%, 50000MB, 0, 150GB | Company | Text Box | 50GB | Defines Company baseline limit for 1024-4096 GB drives on Workstations. Overridden if Site or Endpoint limit exists. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. |
| EDSM_1024To4096Threshold_Svr | 10%, 50000MB, 0, 150GB | Site | Text Box | Defines Site-level limit for 1024-4096 GB drives on Servers. Overrides Company level, but overridden by Endpoint. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. | |
| EDSM_1024To4096Threshold_Wks | 10%, 50000MB, 0, 150GB | Site | Text Box | Defines Site-level limit for 1024-4096 GB drives on Workstations. Overrides Company level, but overridden by Endpoint. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. | |
| EDSM_1024To4096Threshold | 10%, 50000MB, 0, 150GB | Endpoint | Text Box | Defines Endpoint-level limit for 1024-4096 GB drives. Overrides any Site or Company level setting. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. | |
| EDSM_4096PlusThreshold_Svr | 10%, 75000MB, 0, 750GB | Company | Text Box | 100GB | Defines Company baseline limit for 4096+ GB drives on Servers. Overridden if Site or Endpoint limit exists. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. |
| EDSM_4096PlusThreshold_Wks | 10%, 75000MB, 0, 750GB | Company | Text Box | 100GB | Defines Company baseline limit for 4096+ GB drives on Workstations. Overridden if Site or Endpoint limit exists. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. |
| EDSM_4096PlusThreshold_Svr | 10%, 75000MB, 0, 750GB | Site | Text Box | Defines Site-level limit for 4096+ GB drives on Servers. Overrides Company level, but overridden by Endpoint. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. | |
| EDSM_4096PlusThreshold_Wks | 10%, 75000MB, 0, 750GB | Site | Text Box | Defines Site-level limit for 4096+ GB drives on Workstations. Overrides Company level, but overridden by Endpoint. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. | |
| EDSM_4096PlusThreshold | 10%, 75000MB, 0, 750GB | Endpoint | Text Box | Defines Endpoint-level limit for 4096+ GB drives. Overrides any Site or Company level setting. Enter X%, XMB, or XGB. Set to 0 to disable. Name must match across levels. | |
| EDSM_DrivesToInclude_Svr | CDEF, All, None | Company | Text Box | Specifies Company baseline server drive letters to monitor. Overridden if Site or Endpoint list exists. Enter sequential letters (e.g., CDEF), All, or None. Name must match exactly. | |
| EDSM_DrivesToInclude_Wks | CDEF, All, None | Company | Text Box | Specifies Company baseline workstation drive letters to monitor. Overridden if Site or Endpoint list exists. Enter sequential letters (e.g., CDEF), All, or None. Name must match exactly. | |
| EDSM_DrivesToInclude_Svr | CDEF, All, None | Site | Text Box | Specifies Site-level server drive letters to monitor. Overrides Company level, but overridden by Endpoint. Enter sequential letters (e.g., CDEF), All, or None. Name must match exactly. | |
| EDSM_DrivesToInclude_Wks | CDEF, All, None | Site | Text Box | Specifies Site-level workstation drive letters to monitor. Overrides Company level, but overridden by Endpoint. Enter sequential letters (e.g., CDEF), All, or None. Name must match exactly. | |
| EDSM_DrivesToInclude | CDEF, All, None | Endpoint | Text Box | Specifies Endpoint-level drive letters to monitor. Overrides any Site or Company level setting. Enter sequential letters (e.g., CDEF), All, or None. Name must match exactly. | |
| EDSM_DrivesToExclude_Svr | Z, None, All | Company | Text Box | Specifies Company baseline server drive letters to ignore. Overridden if Site or Endpoint list exists. Enter sequential letters (e.g., Z), None, or All. Name must match exactly. | |
| EDSM_DrivesToExclude_Wks | Z, None, All | Company | Text Box | Specifies Company baseline workstation drive letters to ignore. Overridden if Site or Endpoint list exists. Enter sequential letters (e.g., Z), None, or All. Name must match exactly. | |
| EDSM_DrivesToExclude_Svr | Z, None, All | Site | Text Box | Specifies Site-level server drive letters to ignore. Overrides Company level, but overridden by Endpoint. Enter sequential letters (e.g., Z), None, or All. Name must match exactly. | |
| EDSM_DrivesToExclude_Wks | Z, None, All | Site | Text Box | Specifies Site-level workstation drive letters to ignore. Overrides Company level, but overridden by Endpoint. Enter sequential letters (e.g., Z), None, or All. Name must match exactly. | |
| EDSM_DrivesToExclude | Z, None, All | Endpoint | Text Box | Specifies Endpoint-level drive letters to ignore. Overrides any Site or Company level setting. Enter sequential letters (e.g., Z), None, or All. Name must match exactly. |

Task Setup Path
- Tasks Path:
AUTOMATION➞Tasks - Task Type:
Script Editor
Task Creation
Description
- Name:
Enhanced Drive Space Monitoring Configuration Writer - Description:
Resolves hierarchical custom field thresholds and writes a JSON config file for the external drive space monitor set.
Defaults = 10% (16‑300 GB), 30 GB (300‑1024 GB), 50 GB (1024‑4096 GB), 100 GB (4096+ GB)
Output File = %ProgramData%\_Automation\Script\EnhancedDriveSpaceMonitoring\EnhancedDriveSpaceMonitoring.json
- Category:
Monitoring

Script Editor
Row 1 Function: Set Pre-defined Variable ( @computerLevel16To300Threshold@ = EDSM_16To300Threshold )
- Notes:
computerLevel16To300Threshold - Continue on Failure:
False - Operating System:
Windows - Variable Name:
computerLevel16To300Threshold - Custom Field:
EDSM_16To300Threshold (STRING - ENDPOINT)
Row 2 Function: Set Pre-defined Variable ( @computerLevel300to1024Threshold@ = EDSM_300To1024Threshold )
- Notes:
computerLevel300to1024Threshold - Continue on Failure:
False - Operating System:
Windows - Variable Name:
computerLevel300to1024Threshold - Custom Field:
EDSM_300To1024Threshold (STRING - ENDPOINT)
Row 3 Function: Set Pre-defined Variable ( @computerLevel1024to4096Threshold@ = EDSM_1024To4096Threshold )
- Notes:
computerLevel1024to4096Threshold - Continue on Failure:
False - Operating System:
Windows - Variable Name:
computerLevel1024to4096Threshold - Custom Field:
EDSM_1024To4096Threshold (STRING - ENDPOINT)
Row 4 Function: Set Pre-defined Variable ( @computerLevel4096PlusThreshold@ = EDSM_4096PlusThreshold )
- Notes:
computerLevel4096PlusThreshold - Continue on Failure:
False - Operating System:
Windows - Variable Name:
computerLevel4096PlusThreshold - Custom Field:
EDSM_4096PlusThreshold (STRING - ENDPOINT)
Row 5 Function: Set Pre-defined Variable ( @computerLevelDrivesToInclude@ = EDSM_DrivesToInclude )
- Notes:
computerLevelDrivesToInclude - Continue on Failure:
False - Operating System:
Windows - Variable Name:
computerLevelDrivesToInclude - Custom Field:
EDSM_DrivesToInclude (STRING - ENDPOINT)
Row 6 Function: Set Pre-defined Variable ( @computerLevelDrivesToExclude@ = EDSM_DrivesToExclude )
- Notes:
computerLevelDrivesToExclude - Continue on Failure:
False - Operating System:
Windows - Variable Name:
computerLevelDrivesToExclude - Custom Field:
EDSM_DrivesToExclude (STRING - ENDPOINT)
Row 7 Function: Set Pre-defined Variable ( @locationLevel16To300Threshold_Svr@ = EDSM_16To300Threshold_Svr )
- Notes:
locationLevel16To300Threshold_Svr - Continue on Failure:
False - Operating System:
Windows - Variable Name:
locationLevel16To300Threshold_Svr - Custom Field:
EDSM_16To300Threshold_Svr (STRING - SITE)
Row 8 Function: Set Pre-defined Variable ( @locationLevel16To300Threshold_Wks@ = EDSM_16To300Threshold_Wks )
- Notes:
locationLevel16To300Threshold_Wks - Continue on Failure:
False - Operating System:
Windows - Variable Name:
locationLevel16To300Threshold_Wks - Custom Field:
EDSM_16To300Threshold_Wks (STRING - SITE)
Row 9 Function: Set Pre-defined Variable ( @locationLevel300to1024Threshold_Svr@ = EDSM_300To1024Threshold_Svr )
- Notes:
locationLevel300to1024Threshold_Svr - Continue on Failure:
False - Operating System:
Windows - Variable Name:
locationLevel300to1024Threshold_Svr - Custom Field:
EDSM_300To1024Threshold_Svr (STRING - SITE)
Row 10 Function: Set Pre-defined Variable ( @locationLevel300to1024Threshold_Wks@ = EDSM_300To1024Threshold_Wks )
- Notes:
locationLevel300to1024Threshold_Wks - Continue on Failure:
False - Operating System:
Windows - Variable Name:
locationLevel300to1024Threshold_Wks - Custom Field:
EDSM_300To1024Threshold_Wks (STRING - SITE)
Row 11 Function: Set Pre-defined Variable ( @locationLevel1024to4096Threshold_Svr@ = EDSM_1024To4096Threshold_Svr )
- Notes:
locationLevel1024to4096Threshold_Svr - Continue on Failure:
False - Operating System:
Windows - Variable Name:
locationLevel1024to4096Threshold_Svr - Custom Field:
EDSM_1024To4096Threshold_Svr (STRING - SITE)
Row 12 Function: Set Pre-defined Variable ( @locationLevel1024to4096Threshold_Wks@ = EDSM_1024To4096Threshold_Wks )
- Notes:
locationLevel1024to4096Threshold_Wks - Continue on Failure:
False - Operating System:
Windows - Variable Name:
locationLevel1024to4096Threshold_Wks - Custom Field:
EDSM_1024To4096Threshold_Wks (STRING - SITE)
Row 13 Function: Set Pre-defined Variable ( @locationLevel4096PlusThreshold_Svr@ = EDSM_4096PlusThreshold_Svr )
- Notes:
locationLevel4096PlusThreshold_Svr - Continue on Failure:
False - Operating System:
Windows - Variable Name:
locationLevel4096PlusThreshold_Svr - Custom Field:
EDSM_4096PlusThreshold_Svr (STRING - SITE)
Row 14 Function: Set Pre-defined Variable ( @locationLevel4096PlusThreshold_Wks@ = EDSM_4096PlusThreshold_Wks )
- Notes:
locationLevel4096PlusThreshold_Wks - Continue on Failure:
False - Operating System:
Windows - Variable Name:
locationLevel4096PlusThreshold_Wks - Custom Field:
EDSM_4096PlusThreshold_Wks (STRING - SITE)
Row 15 Function: Set Pre-defined Variable ( @locationLevelDrivesToInclude_Svr@ = EDSM_DrivesToInclude_Svr )
- Notes:
locationLevelDrivesToInclude_Svr - Continue on Failure:
False - Operating System:
Windows - Variable Name:
locationLevelDrivesToInclude_Svr - Custom Field:
EDSM_DrivesToInclude_Svr (STRING - SITE)
Row 16 Function: Set Pre-defined Variable ( @locationLevelDrivesToInclude_Wks@ = EDSM_DrivesToInclude_Wks )
- Notes:
locationLevelDrivesToInclude_Wks - Continue on Failure:
False - Operating System:
Windows - Variable Name:
locationLevelDrivesToInclude_Wks - Custom Field:
EDSM_DrivesToInclude_Wks (STRING - SITE)
Row 17 Function: Set Pre-defined Variable ( @locationLevelDrivesToExclude_Svr@ = EDSM_DrivesToExclude_Svr )
- Notes:
locationLevelDrivesToExclude_Svr - Continue on Failure:
False - Operating System:
Windows - Variable Name:
locationLevelDrivesToExclude_Svr - Custom Field:
EDSM_DrivesToExclude_Svr (STRING - SITE)
Row 18 Function: Set Pre-defined Variable ( @locationLevelDrivesToExclude_Wks@ = EDSM_DrivesToExclude_Wks )
- Notes:
locationLevelDrivesToExclude_Wks - Continue on Failure:
False - Operating System:
Windows - Variable Name:
locationLevelDrivesToExclude_Wks - Custom Field:
EDSM_DrivesToExclude_Wks (STRING - SITE)
Row 19 Function: Set Pre-defined Variable ( @clientLevel16To300Threshold_Svr@ = EDSM_16To300Threshold_Svr )
- Notes:
clientLevel16To300Threshold_Svr - Continue on Failure:
False - Operating System:
Windows - Variable Name:
clientLevel16To300Threshold_Svr - Custom Field:
EDSM_16To300Threshold_Svr (STRING - COMPANY)
Row 20 Function: Set Pre-defined Variable ( @clientLevel16To300Threshold_Wks@ = EDSM_16To300Threshold_Wks )
- Notes:
clientLevel16To300Threshold_Wks - Continue on Failure:
False - Operating System:
Windows - Variable Name:
clientLevel16To300Threshold_Wks - Custom Field:
EDSM_16To300Threshold_Wks (STRING - COMPANY)
Row 21 Function: Set Pre-defined Variable ( @clientLevel300to1024Threshold_Svr@ = EDSM_300To1024Threshold_Svr )
- Notes:
clientLevel300to1024Threshold_Svr - Continue on Failure:
False - Operating System:
Windows - Variable Name:
clientLevel300to1024Threshold_Svr - Custom Field:
EDSM_300To1024Threshold_Svr (STRING - COMPANY)
Row 22 Function: Set Pre-defined Variable ( @clientLevel300to1024Threshold_Wks@ = EDSM_300To1024Threshold_Wks )
- Notes:
clientLevel300to1024Threshold_Wks - Continue on Failure:
False - Operating System:
Windows - Variable Name:
clientLevel300to1024Threshold_Wks - Custom Field:
EDSM_300To1024Threshold_Wks (STRING - COMPANY)
Row 23 Function: Set Pre-defined Variable ( @clientLevel1024to4096Threshold_Svr@ = EDSM_1024To4096Threshold_Svr )
- Notes:
clientLevel1024to4096Threshold_Svr - Continue on Failure:
False - Operating System:
Windows - Variable Name:
clientLevel1024to4096Threshold_Svr - Custom Field:
EDSM_1024To4096Threshold_Svr (STRING - COMPANY)
Row 24 Function: Set Pre-defined Variable ( @clientLevel1024to4096Threshold_Wks@ = EDSM_1024To4096Threshold_Wks )
- Notes:
clientLevel1024to4096Threshold_Wks - Continue on Failure:
False - Operating System:
Windows - Variable Name:
clientLevel1024to4096Threshold_Wks - Custom Field:
EDSM_1024To4096Threshold_Wks (STRING - COMPANY)
Row 25 Function: Set Pre-defined Variable ( @clientLevel4096PlusThreshold_Svr@ = EDSM_4096PlusThreshold_Svr )
- Notes:
clientLevel4096PlusThreshold_Svr - Continue on Failure:
False - Operating System:
Windows - Variable Name:
clientLevel4096PlusThreshold_Svr - Custom Field:
EDSM_4096PlusThreshold_Svr (STRING - COMPANY)
Row 26 Function: Set Pre-defined Variable ( @clientLevel4096PlusThreshold_Wks@ = EDSM_4096PlusThreshold_Wks )
- Notes:
clientLevel4096PlusThreshold_Wks - Continue on Failure:
False - Operating System:
Windows - Variable Name:
clientLevel4096PlusThreshold_Wks - Custom Field:
EDSM_4096PlusThreshold_Wks (STRING - COMPANY)
Row 27 Function: Set Pre-defined Variable ( @clientLevelDrivesToInclude_Svr@ = EDSM_DrivesToInclude_Svr )
- Notes:
clientLevelDrivesToInclude_Svr - Continue on Failure:
False - Operating System:
Windows - Variable Name:
clientLevelDrivesToInclude_Svr - Custom Field:
EDSM_DrivesToInclude_Svr (STRING - COMPANY)
Row 28 Function: Set Pre-defined Variable ( @clientLevelDrivesToInclude_Wks@ = EDSM_DrivesToInclude_Wks )
- Notes:
clientLevelDrivesToInclude_Wks - Continue on Failure:
False - Operating System:
Windows - Variable Name:
clientLevelDrivesToInclude_Wks - Custom Field:
EDSM_DrivesToInclude_Wks (STRING - COMPANY)
Row 29 Function: Set Pre-defined Variable ( @clientLevelDrivesToExclude_Svr@ = EDSM_DrivesToExclude_Svr )
- Notes:
clientLevelDrivesToExclude_Svr - Continue on Failure:
False - Operating System:
Windows - Variable Name:
clientLevelDrivesToExclude_Svr - Custom Field:
EDSM_DrivesToExclude_Svr (STRING - COMPANY)
Row 30 Function: Set Pre-defined Variable ( @clientLevelDrivesToExclude_Wks@ = EDSM_DrivesToExclude_Wks )
- Notes:
clientLevelDrivesToExclude_Wks - Continue on Failure:
False - Operating System:
Windows - Variable Name:
clientLevelDrivesToExclude_Wks - Custom Field:
EDSM_DrivesToExclude_Wks (STRING - COMPANY)
Row 31 Function: PowerShell script
- Notes:
<Leave it Blank> - Use Generative AI Assist for script creation:
False - Expected time of script execution in seconds:
300 - Continue on Failure:
False - Run As:
System - Operating System:
Windows - PowerShell Script Editor:
<#
.SYNOPSIS
Generates a JSON configuration file for drive space threshold monitoring based on CW RMM hierarchical custom fields.
Does NOT perform any monitoring itself.
.DESCRIPTION
This script resolves drive space thresholds (per capacity bucket) and drive inclusion/exclusion lists from
hierarchically defined custom fields in CW RMM, then writes a local configuration file.
A separate monitor set reads this file to perform the actual drive space checks and alerting.
The workflow is:
1. Reads custom fields at Endpoint, Site, and Company levels using the EDSM_ naming convention.
2. Detects the operating system type (Server vs. Workstation) to select the correct field suffixes (_Svr / _Wks).
3. Applies hierarchical override logic: Endpoint > Site > Company, falling back to hard‑coded defaults
(10% for 16‑300 GB, 30 GB for 300‑1024 GB, 50 GB for 1024‑4096 GB, 100 GB for 4096+ GB).
4. Writes a JSON configuration file under %ProgramData%\_Automation\Script\EnhancedDriveSpaceMonitoring\.
The actual monitoring is performed by an external monitor set that reads this configuration file.
This script itself does NOT check any drives or produce alerts.
.COMPONENT
---------------------------------------------------------------------
CW RMM Task Custom Field Mapping
---------------------------------------------------------------------
| Name | Description | Level | Type | Help Text | Default Value | Editable |
|---|---|---|---|---|---|---|
| EDSM_16To300Threshold_Svr | Company baseline limit for 16-300 GB drives on Servers. | Company | Text Box | Enter X%, XMB, or XGB (e.g., 10%). Set to 0 to disable. | 10% | Yes |
| EDSM_16To300Threshold_Wks | Company baseline limit for 16-300 GB drives on Workstations. | Company | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | 10% | Yes |
| EDSM_16To300Threshold_Svr | Site‑level limit for 16-300 GB drives on Servers. | Site | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | | Yes |
| EDSM_16To300Threshold_Wks | Site‑level limit for 16-300 GB drives on Workstations. | Site | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | | Yes |
| EDSM_16To300Threshold | Endpoint‑level limit for 16-300 GB drives. | Endpoint | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | | Yes |
| EDSM_300To1024Threshold_Svr | Company baseline limit for 300-1024 GB drives on Servers. | Company | Text Box | Enter X%, XMB, or XGB (e.g., 30GB). Set to 0 to disable. | 30GB | Yes |
| EDSM_300To1024Threshold_Wks | Company baseline limit for 300-1024 GB drives on Workstations. | Company | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | 30GB | Yes |
| EDSM_300To1024Threshold_Svr | Site‑level limit for 300-1024 GB drives on Servers. | Site | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | | Yes |
| EDSM_300To1024Threshold_Wks | Site‑level limit for 300-1024 GB drives on Workstations. | Site | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | | Yes |
| EDSM_300To1024Threshold | Endpoint‑level limit for 300-1024 GB drives. | Endpoint | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | | Yes |
| EDSM_1024To4096Threshold_Svr | Company baseline limit for 1024-4096 GB drives on Servers. | Company | Text Box | Enter X%, XMB, or XGB (e.g., 50GB). Set to 0 to disable. | 50GB | Yes |
| EDSM_1024To4096Threshold_Wks | Company baseline limit for 1024-4096 GB drives on Workstations. | Company | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | 50GB | Yes |
| EDSM_1024To4096Threshold_Svr | Site‑level limit for 1024-4096 GB drives on Servers. | Site | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | | Yes |
| EDSM_1024To4096Threshold_Wks | Site‑level limit for 1024-4096 GB drives on Workstations. | Site | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | | Yes |
| EDSM_1024To4096Threshold | Endpoint‑level limit for 1024-4096 GB drives. | Endpoint | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | | Yes |
| EDSM_4096PlusThreshold_Svr | Company baseline limit for 4096+ GB drives on Servers. | Company | Text Box | Enter X%, XMB, or XGB (e.g., 100GB). Set to 0 to disable. | 100GB | Yes |
| EDSM_4096PlusThreshold_Wks | Company baseline limit for 4096+ GB drives on Workstations. | Company | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | 100GB | Yes |
| EDSM_4096PlusThreshold_Svr | Site‑level limit for 4096+ GB drives on Servers. | Site | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | | Yes |
| EDSM_4096PlusThreshold_Wks | Site‑level limit for 4096+ GB drives on Workstations. | Site | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | | Yes |
| EDSM_4096PlusThreshold | Endpoint‑level limit for 4096+ GB drives. | Endpoint | Text Box | Enter X%, XMB, or XGB. Set to 0 to disable. | | Yes |
| EDSM_DrivesToInclude_Svr | Company baseline server drive letters to monitor. | Company | Text Box | Enter sequential letters (e.g., CDEF), All, or None. | | Yes |
| EDSM_DrivesToInclude_Wks | Company baseline workstation drive letters to monitor. | Company | Text Box | Enter sequential letters (e.g., CDEF), All, or None. | | Yes |
| EDSM_DrivesToInclude_Svr | Site‑level server drive letters to monitor. | Site | Text Box | Enter sequential letters (e.g., CDEF), All, or None. | | Yes |
| EDSM_DrivesToInclude_Wks | Site‑level workstation drive letters to monitor. | Site | Text Box | Enter sequential letters (e.g., CDEF), All, or None. | | Yes |
| EDSM_DrivesToInclude | Endpoint‑level drive letters to monitor. | Endpoint | Text Box | Enter sequential letters (e.g., CDEF), All, or None. | | Yes |
| EDSM_DrivesToExclude_Svr | Company baseline server drive letters to ignore. | Company | Text Box | Enter sequential letters (e.g., Z), None, or All. | | Yes |
| EDSM_DrivesToExclude_Wks | Company baseline workstation drive letters to ignore. | Company | Text Box | Enter sequential letters (e.g., Z), None, or All. | | Yes |
| EDSM_DrivesToExclude_Svr | Site‑level server drive letters to ignore. | Site | Text Box | Enter sequential letters (e.g., Z), None, or All. | | Yes |
| EDSM_DrivesToExclude_Wks | Site‑level workstation drive letters to ignore. | Site | Text Box | Enter sequential letters (e.g., Z), None, or All. | | Yes |
| EDSM_DrivesToExclude | Endpoint‑level drive letters to ignore. | Endpoint | Text Box | Enter sequential letters (e.g., Z), None, or All. | | Yes |
---------------------------------------------------------------------
Enablement Fields (not used by this script)
---------------------------------------------------------------------
The EDSM_Enable* fields are consumed exclusively by CW RMM automation groups. They are not
read by this configuration writer.
| Name | Description | Level | Type | Option Type | Options | Help Text | Default Value | Editable |
|---|---|---|---|---|---|---|---|---|
| EDSM_Enable_Svr | Enables or disables drive space monitoring for servers at the Company level. Overridden by Site or Endpoint settings. | Company | Dropdown | String | Enable, Disable | Select Enable to turn on monitoring, Disable to exclude. | | Yes |
| EDSM_Enable_Wks | Enables or disables drive space monitoring for workstations at the Company level. Overridden by Site or Endpoint settings. | Company | Dropdown | String | Enable, Disable | Select Enable to turn on monitoring, Disable to exclude. | | Yes |
| EDSM_Enable_Svr_Site | Enables or disables drive space monitoring for servers at the Site level. Overrides Company settings, but overridden by Endpoint. | Site | Dropdown | String | Enable, Disable | Select Enable to turn on monitoring, Disable to exclude. | | Yes |
| EDSM_Enable_Wks_Site | Enables or disables drive space monitoring for workstations at the Site level. Overrides Company settings, but overridden by Endpoint. | Site | Dropdown | String | Enable, Disable | Select Enable to turn on monitoring, Disable to exclude. | | Yes |
| EDSM_Enable | Enables or disables drive space monitoring at the Endpoint level. Overrides any Company or Site settings. | Endpoint | Dropdown | String | Enable, Disable | Select Enable to turn on monitoring, Disable to exclude. | | Yes |
.NOTES
ScriptName = Enhanced Drive Space Monitoring Configuration Writer
Description = Resolves hierarchical custom field thresholds and writes a JSON config file
for the external drive space monitor set.
Defaults = 10% (16‑300 GB), 30 GB (300‑1024 GB), 50 GB (1024‑4096 GB), 100 GB (4096+ GB)
Output File = %ProgramData%\_Automation\Script\EnhancedDriveSpaceMonitoring\EnhancedDriveSpaceMonitoring.json
.OUTPUTS
Writes the JSON configuration file. Returns nothing on success.
Throws a terminating error if the working directory or config file cannot be written.
#>
#region globals
$ProgressPreference = 'SilentlyContinue'
$WarningPreference = 'SilentlyContinue'
#endregion
#region variables
$projectName = 'EnhancedDriveSpaceMonitoring'
$workingDirectory = '{0}\_Automation\Script\{1}' -f $env:ProgramData, $projectName
$configFilePath = '{0}\{1}.json' -f $workingDirectory, $projectName
#endregion
#region rmm variables
# Endpoint Level (Base Variables)
$computerLevel16To300Threshold = '@computerLevel16To300Threshold@'
$computerLevel300to1024Threshold = '@computerLevel300to1024Threshold@'
$computerLevel1024to4096Threshold = '@computerLevel1024to4096Threshold@'
$computerLevel4096PlusThreshold = '@computerLevel4096PlusThreshold@'
$computerLevelDrivesToInclude = '@computerLevelDrivesToInclude@'
$computerLevelDrivesToExclude = '@computerLevelDrivesToExclude@'
# Site/Location Level (Server & Workstation splits)
$locationLevel16To300Threshold_Svr = '@locationLevel16To300Threshold_Svr@'
$locationLevel16To300Threshold_Wks = '@locationLevel16To300Threshold_Wks@'
$locationLevel300to1024Threshold_Svr = '@locationLevel300to1024Threshold_Svr@'
$locationLevel300to1024Threshold_Wks = '@locationLevel300to1024Threshold_Wks@'
$locationLevel1024to4096Threshold_Svr = '@locationLevel1024to4096Threshold_Svr@'
$locationLevel1024to4096Threshold_Wks = '@locationLevel1024to4096Threshold_Wks@'
$locationLevel4096PlusThreshold_Svr = '@locationLevel4096PlusThreshold_Svr@'
$locationLevel4096PlusThreshold_Wks = '@locationLevel4096PlusThreshold_Wks@'
$locationLevelDrivesToInclude_Svr = '@locationLevelDrivesToInclude_Svr@'
$locationLevelDrivesToInclude_Wks = '@locationLevelDrivesToInclude_Wks@'
$locationLevelDrivesToExclude_Svr = '@locationLevelDrivesToExclude_Svr@'
$locationLevelDrivesToExclude_Wks = '@locationLevelDrivesToExclude_Wks@'
# Company/Client Level (Server & Workstation splits)
$clientLevel16To300Threshold_Svr = '@clientLevel16To300Threshold_Svr@'
$clientLevel16To300Threshold_Wks = '@clientLevel16To300Threshold_Wks@'
$clientLevel300to1024Threshold_Svr = '@clientLevel300to1024Threshold_Svr@'
$clientLevel300to1024Threshold_Wks = '@clientLevel300to1024Threshold_Wks@'
$clientLevel1024to4096Threshold_Svr = '@clientLevel1024to4096Threshold_Svr@'
$clientLevel1024to4096Threshold_Wks = '@clientLevel1024to4096Threshold_Wks@'
$clientLevel4096PlusThreshold_Svr = '@clientLevel4096PlusThreshold_Svr@'
$clientLevel4096PlusThreshold_Wks = '@clientLevel4096PlusThreshold_Wks@'
$clientLevelDrivesToInclude_Svr = '@clientLevelDrivesToInclude_Svr@'
$clientLevelDrivesToInclude_Wks = '@clientLevelDrivesToInclude_Wks@'
$clientLevelDrivesToExclude_Svr = '@clientLevelDrivesToExclude_Svr@'
$clientLevelDrivesToExclude_Wks = '@clientLevelDrivesToExclude_Wks@'
#endregion
#region os detection & variable mapping
$osInfo = Get-CimInstance -ClassName 'Win32_OperatingSystem' -ErrorAction SilentlyContinue
$isServer = $osInfo.ProductType -ne 1
if ($isServer) {
$clientLevel16To300Threshold = $clientLevel16To300Threshold_Svr
$locationLevel16To300Threshold = $locationLevel16To300Threshold_Svr
$clientLevel300to1024Threshold = $clientLevel300to1024Threshold_Svr
$locationLevel300to1024Threshold = $locationLevel300to1024Threshold_Svr
$clientLevel1024to4096Threshold = $clientLevel1024to4096Threshold_Svr
$locationLevel1024to4096Threshold = $locationLevel1024to4096Threshold_Svr
$clientLevel4096PlusThreshold = $clientLevel4096PlusThreshold_Svr
$locationLevel4096PlusThreshold = $locationLevel4096PlusThreshold_Svr
$clientLevelDrivesToInclude = $clientLevelDrivesToInclude_Svr
$locationLevelDrivesToInclude = $locationLevelDrivesToInclude_Svr
$clientLevelDrivesToExclude = $clientLevelDrivesToExclude_Svr
$locationLevelDrivesToExclude = $locationLevelDrivesToExclude_Svr
} else {
$clientLevel16To300Threshold = $clientLevel16To300Threshold_Wks
$locationLevel16To300Threshold = $locationLevel16To300Threshold_Wks
$clientLevel300to1024Threshold = $clientLevel300to1024Threshold_Wks
$locationLevel300to1024Threshold = $locationLevel300to1024Threshold_Wks
$clientLevel1024to4096Threshold = $clientLevel1024to4096Threshold_Wks
$locationLevel1024to4096Threshold = $locationLevel1024to4096Threshold_Wks
$clientLevel4096PlusThreshold = $clientLevel4096PlusThreshold_Wks
$locationLevel4096PlusThreshold = $locationLevel4096PlusThreshold_Wks
$clientLevelDrivesToInclude = $clientLevelDrivesToInclude_Wks
$locationLevelDrivesToInclude = $locationLevelDrivesToInclude_Wks
$clientLevelDrivesToExclude = $clientLevelDrivesToExclude_Wks
$locationLevelDrivesToExclude = $locationLevelDrivesToExclude_Wks
}
#endregion
#region set thresholds based on rmm variables (hierarchical override)
# 16‑300 GB bucket
[int]$16To300Threshold = if (-not [string]::IsNullOrEmpty($computerLevel16To300Threshold) -and $computerLevel16To300Threshold -notmatch 'computerLevel16To300Threshold' -and $computerLevel16To300Threshold -match '^([1-9]\d?%|[1-9]\d*[MG]B)$') {
[regex]::Match($computerLevel16To300Threshold, '[1-9]\d*').Value
} elseif (-not [string]::IsNullOrEmpty($locationLevel16To300Threshold) -and $locationLevel16To300Threshold -notmatch 'locationLevel16To300Threshold' -and $locationLevel16To300Threshold -match '^([1-9]\d?%|[1-9]\d*[MG]B)$') {
[regex]::Match($locationLevel16To300Threshold, '[1-9]\d*').Value
} elseif (-not [string]::IsNullOrEmpty($clientLevel16To300Threshold) -and $clientLevel16To300Threshold -notmatch 'clientLevel16To300Threshold' -and $clientLevel16To300Threshold -match '^([1-9]\d?%|[1-9]\d*[MG]B)$') {
[regex]::Match($clientLevel16To300Threshold, '[1-9]\d*').Value
} else {
10
}
$16To300Unit = if ($computerLevel16To300Threshold -match '[1-9]\d?%') {
'Percent'
} elseif ($computerLevel16To300Threshold -match '[1-9]\d*MB') {
'MB'
} elseif ($computerLevel16To300Threshold -match '[1-9]\d*GB') {
'GB'
} elseif ($locationLevel16To300Threshold -match '[1-9]\d?%') {
'Percent'
} elseif ($locationLevel16To300Threshold -match '[1-9]\d*MB') {
'MB'
} elseif ($locationLevel16To300Threshold -match '[1-9]\d*GB') {
'GB'
} elseif ($clientLevel16To300Threshold -match '[1-9]\d?%') {
'Percent'
} elseif ($clientLevel16To300Threshold -match '[1-9]\d*MB') {
'MB'
} elseif ($clientLevel16To300Threshold -match '[1-9]\d*GB') {
'GB'
} else {
'Percent'
}
# 300‑1024 GB bucket
[int]$300To1024Threshold = if (-not [string]::IsNullOrEmpty($computerLevel300to1024Threshold) -and $computerLevel300to1024Threshold -notmatch 'computerLevel300to1024Threshold' -and $computerLevel300to1024Threshold -match '^([1-9]\d?%|[1-9]\d*[MG]B)$') {
[regex]::Match($computerLevel300to1024Threshold, '[1-9]\d*').Value
} elseif (-not [string]::IsNullOrEmpty($locationLevel300to1024Threshold) -and $locationLevel300to1024Threshold -notmatch 'locationLevel300to1024Threshold' -and $locationLevel300to1024Threshold -match '^([1-9]\d?%|[1-9]\d*[MG]B)$') {
[regex]::Match($locationLevel300to1024Threshold, '[1-9]\d*').Value
} elseif (-not [string]::IsNullOrEmpty($clientLevel300to1024Threshold) -and $clientLevel300to1024Threshold -notmatch 'clientLevel300to1024Threshold' -and $clientLevel300to1024Threshold -match '^([1-9]\d?%|[1-9]\d*[MG]B)$') {
[regex]::Match($clientLevel300to1024Threshold, '[1-9]\d*').Value
} else {
30
}
$300To1024Unit = if ($computerLevel300to1024Threshold -match '[1-9]\d?%') {
'Percent'
} elseif ($computerLevel300to1024Threshold -match '[1-9]\d*MB') {
'MB'
} elseif ($computerLevel300to1024Threshold -match '[1-9]\d*GB') {
'GB'
} elseif ($locationLevel300to1024Threshold -match '[1-9]\d?%') {
'Percent'
} elseif ($locationLevel300to1024Threshold -match '[1-9]\d*MB') {
'MB'
} elseif ($locationLevel300to1024Threshold -match '[1-9]\d*GB') {
'GB'
} elseif ($clientLevel300to1024Threshold -match '[1-9]\d?%') {
'Percent'
} elseif ($clientLevel300to1024Threshold -match '[1-9]\d*MB') {
'MB'
} elseif ($clientLevel300to1024Threshold -match '[1-9]\d*GB') {
'GB'
} else {
'GB'
}
# 1024‑4096 GB bucket
[int]$1024To4096Threshold = if (-not [string]::IsNullOrEmpty($computerLevel1024to4096Threshold) -and $computerLevel1024to4096Threshold -notmatch 'computerLevel1024to4096Threshold' -and $computerLevel1024to4096Threshold -match '^([1-9]\d?%|[1-9]\d*[MG]B)$') {
[regex]::Match($computerLevel1024to4096Threshold, '[1-9]\d*').Value
} elseif (-not [string]::IsNullOrEmpty($locationLevel1024to4096Threshold) -and $locationLevel1024to4096Threshold -notmatch 'locationLevel1024to4096Threshold' -and $locationLevel1024to4096Threshold -match '^([1-9]\d?%|[1-9]\d*[MG]B)$') {
[regex]::Match($locationLevel1024to4096Threshold, '[1-9]\d*').Value
} elseif (-not [string]::IsNullOrEmpty($clientLevel1024to4096Threshold) -and $clientLevel1024to4096Threshold -notmatch 'clientLevel1024to4096Threshold' -and $clientLevel1024to4096Threshold -match '^([1-9]\d?%|[1-9]\d*[MG]B)$') {
[regex]::Match($clientLevel1024to4096Threshold, '[1-9]\d*').Value
} else {
50
}
$1024To4096Unit = if ($computerLevel1024to4096Threshold -match '[1-9]\d?%') {
'Percent'
} elseif ($computerLevel1024to4096Threshold -match '[1-9]\d*MB') {
'MB'
} elseif ($computerLevel1024to4096Threshold -match '[1-9]\d*GB') {
'GB'
} elseif ($locationLevel1024to4096Threshold -match '[1-9]\d?%') {
'Percent'
} elseif ($locationLevel1024to4096Threshold -match '[1-9]\d*MB') {
'MB'
} elseif ($locationLevel1024to4096Threshold -match '[1-9]\d*GB') {
'GB'
} elseif ($clientLevel1024to4096Threshold -match '[1-9]\d?%') {
'Percent'
} elseif ($clientLevel1024to4096Threshold -match '[1-9]\d*MB') {
'MB'
} elseif ($clientLevel1024to4096Threshold -match '[1-9]\d*GB') {
'GB'
} else {
'GB'
}
# 4096+ GB bucket
[int]$4096PlusThreshold = if (-not [string]::IsNullOrEmpty($computerLevel4096PlusThreshold) -and $computerLevel4096PlusThreshold -notmatch 'computerLevel4096PlusThreshold' -and $computerLevel4096PlusThreshold -match '^([1-9]\d?%|[1-9]\d*[MG]B)$') {
[regex]::Match($computerLevel4096PlusThreshold, '[1-9]\d*').Value
} elseif (-not [string]::IsNullOrEmpty($locationLevel4096PlusThreshold) -and $locationLevel4096PlusThreshold -notmatch 'locationLevel4096PlusThreshold' -and $locationLevel4096PlusThreshold -match '^([1-9]\d?%|[1-9]\d*[MG]B)$') {
[regex]::Match($locationLevel4096PlusThreshold, '[1-9]\d*').Value
} elseif (-not [string]::IsNullOrEmpty($clientLevel4096PlusThreshold) -and $clientLevel4096PlusThreshold -notmatch 'clientLevel4096PlusThreshold' -and $clientLevel4096PlusThreshold -match '^([1-9]\d?%|[1-9]\d*[MG]B)$') {
[regex]::Match($clientLevel4096PlusThreshold, '[1-9]\d*').Value
} else {
100
}
$4096PlusUnit = if ($computerLevel4096PlusThreshold -match '[1-9]\d?%') {
'Percent'
} elseif ($computerLevel4096PlusThreshold -match '[1-9]\d*MB') {
'MB'
} elseif ($computerLevel4096PlusThreshold -match '[1-9]\d*GB') {
'GB'
} elseif ($locationLevel4096PlusThreshold -match '[1-9]\d?%') {
'Percent'
} elseif ($locationLevel4096PlusThreshold -match '[1-9]\d*MB') {
'MB'
} elseif ($locationLevel4096PlusThreshold -match '[1-9]\d*GB') {
'GB'
} elseif ($clientLevel4096PlusThreshold -match '[1-9]\d?%') {
'Percent'
} elseif ($clientLevel4096PlusThreshold -match '[1-9]\d*MB') {
'MB'
} elseif ($clientLevel4096PlusThreshold -match '[1-9]\d*GB') {
'GB'
} else {
'GB'
}
# Inclusion / Exclusion lists
$includedDrives = if (-not [string]::IsNullOrEmpty($computerLevelDrivesToInclude) -and $computerLevelDrivesToInclude -notmatch 'computerLevelDrivesToInclude') {
$computerLevelDrivesToInclude
} elseif (-not [string]::IsNullOrEmpty($locationLevelDrivesToInclude) -and $locationLevelDrivesToInclude -notmatch 'locationLevelDrivesToInclude') {
$locationLevelDrivesToInclude
} elseif (-not [string]::IsNullOrEmpty($clientLevelDrivesToInclude) -and $clientLevelDrivesToInclude -notmatch 'clientLevelDrivesToInclude') {
$clientLevelDrivesToInclude
} else {
'All'
}
$excludedDrives = if (-not [string]::IsNullOrEmpty($computerLevelDrivesToExclude) -and $computerLevelDrivesToExclude -notmatch 'computerLevelDrivesToExclude') {
$computerLevelDrivesToExclude
} elseif (-not [string]::IsNullOrEmpty($locationLevelDrivesToExclude) -and $locationLevelDrivesToExclude -notmatch 'locationLevelDrivesToExclude') {
$locationLevelDrivesToExclude
} elseif (-not [string]::IsNullOrEmpty($clientLevelDrivesToExclude) -and $clientLevelDrivesToExclude -notmatch 'clientLevelDrivesToExclude') {
$clientLevelDrivesToExclude
} else {
'None'
}
#endregion
#region working directory
if (-not (Test-Path -Path $workingDirectory)) {
try {
New-Item -Path $workingDirectory -ItemType Directory -Force -ErrorAction Stop | Out-Null
} catch {
throw ('Failed to create the working directory {2}{0}{2}. Error: {1}' -f $workingDirectory, $Error[0].Exception.Message, [char]34)
}
}
#endregion
#region config file
$config = [ordered]@{
Thresholds = @(
[ordered]@{
Bucket = '16To300'
Value = $16To300Threshold
Unit = $16To300Unit
}
[ordered]@{
Bucket = '300To1024'
Value = $300To1024Threshold
Unit = $300To1024Unit
}
[ordered]@{
Bucket = '1024To4096'
Value = $1024To4096Threshold
Unit = $1024To4096Unit
}
[ordered]@{
Bucket = '4096Plus'
Value = $4096PlusThreshold
Unit = $4096PlusUnit
}
)
IncludeDrives = $includedDrives
ExcludeDrives = $excludedDrives
}
try {
$config | ConvertTo-Json -Depth 3 | Set-Content -Path $configFilePath -Force -Encoding UTF8 -ErrorAction Stop
} catch {
throw ('Failed to write the configuration file {2}{0}{2}. Error: {1}' -f $configFilePath, $Error[0].Exception.Message, [char]34)
}
return ('Configuration file ''{0}'' written successfully.{1}{1}Configuration:{1}{2}' -f $configFilePath, [System.Environment]::NewLine, ($config | Out-String))
#endregion

Row 32 Function: Script Log
- Notes:
<Leave it Blank> - Continue on Failure:
False - Operating System:
Windows - Script Log Message:
%Output%
Completed Task

Output
- Script Log
- JSON File at
C:\ProgramData\_Automation\Script\EnhancedDriveSpaceMonitoring\EnhancedDriveSpaceMonitoring.json
Schedule Task
Task Details
- Name:
Enhanced Drive Space Monitoring Configuration Writer - Description:
Resolves hierarchical custom field thresholds and writes a JSON config file for the external drive space monitor set.
Defaults = 10% (16‑300 GB), 30 GB (300‑1024 GB), 50 GB (1024‑4096 GB), 100 GB (4096+ GB)
Output File = %ProgramData%\_Automation\Script\EnhancedDriveSpaceMonitoring\EnhancedDriveSpaceMonitoring.json
- Category:
Monitoring

Schedule
- Schedule Type:
Schedule - Timezone:
Local Machine Time - Start:
<Current Date> - Trigger:
TimeAt<Current Time> - Recurrence:
Every day - Execute at next agent check-in:
True - Stop After:
22 - Unit:
Hour(s)

Targeted Resource
Device Group: Enhanced Drive Space Monitoring

Completed Scheduled Task

Changelog
2026-07-02
- Architecture Change: The task has been converted from a monitoring script that directly generated tickets to a configuration writer. It now only resolves custom field thresholds and writes a JSON configuration file (
EnhancedDriveSpaceMonitoring.json). The actual drive space evaluation and ticketing are handled by a dedicated monitor set that reads this file. This decoupling allows more frequent health checks (via the monitor) while keeping policy management centralized in custom fields.
2026-06-24
- Initial version of the document (original monitoring task).