Skip to main content

CHKDSK - Run All Drives

Overview​

This automation scans all internal fixed drives for bad sectors using a read-only chkdsk. If errors are found and the cpvalChkdskAutofix custom field is set to "Enabled", it schedules an offline repair using chkdsk /F on the target drives. The results and error messages are output directly to the NinjaOne activity log, and the script exits with code 1 to trigger ticket creation via compound condition. Schedule this automation as a routine maintenance task to proactively monitor disk health and automatically remediate corruption before it leads to drive failures.

Note:

Before running this automation, ensure the cpvalChkdskAutofix device custom field is created in NinjaOne. If this field is not set to "Enabled", the script will only report the errors and exit without attempting a repair. Additionally, the script will intentionally show as "Failed" (Exit Code 1) when disk problems are found; this behavior is required to trigger the ticket creation or commenting condition in the NinjaOne policy.


Requirements​

  • Supported operating system and device role
  • Run As: System
  • PowerShell 5.1

Sample Run​

Image1

Custom Fields​

Custom FieldScopeTypeDescription
cPVAL ChkDsk AutofixDevice, Organization, Location, SystemDrop-downThis is used to set if autofix needs to be executed or not during the script run.

Parameters​

NameCalculated NameTypeDefault ValueDescription
CHKDSKAutofixchkdskautofixCheckbox---This is used to run enable the function to run autofix if Checked

Dependencies​

Automation Setup/Import​

Automation Configuration

Output​

  • Activity Details

Changelog​

2026-10-16​

  • Initial version of the document