boostmr2The key here is to run chkdsk (note, no /f) and get the results. Then act based on the results. I have a script that runs checkdisk on all workstations weekly, along with other maintenance items, and spits out a report. Kaseya reads the report, and generates a ticket and logs the data. A technician then manually handles the errors. I may in the future have kaseya auto-schedule the chkdsk /f and prompt the user to reboot and let run.
boostmr2It's amazing how many machines have errors.
Script Name: Chkdsk Step1 Script Description: This script runs chkdsk in read-only mode and dumps a log file to the agent temp directory called chkdsklog.txt. A second script is called to read the results of this script. IF True THEN Get Variable Parameter 1 : 10 Parameter 2 : Parameter 3 : AgentTemp OS Type : 0 Execute Shell Command Parameter 1 : chkdsk c: >> #AgentTemp#\chkdsklog.txt Parameter 2 : 1 OS Type : 0 Get Variable Parameter 1 : 1 Parameter 2 : #AgentTemp#\chkdsklog.txt Parameter 3 : chkdsklog OS Type : 0 Execute Script Parameter 1 : Chkdsk Step2 (NOTE: Script reference is NOT imported. Correct manually in script editor. Parameter 2 : Parameter 3 : 0 OS Type : 0 ELSE
Script Name: Chkdsk Step2 Script Description: Part 2 of 2. This script parses the chkdsk log looking for the existence of 'total disk space.' and re-runs the script in an hour if it is not discovered. If the value is found, Chkdsk Step3 is executed to find mention that 'Windows found problems with the file system.' The chkdsklog.txt file is deleted after the script executes. IF Check Variable Parameter 1 : #chkdsklog# Not Contains :total disk space. THEN Get Variable Parameter 1 : 6 Parameter 2 : Parameter 3 : MachineID OS Type : 0 Write Script Log Entry Parameter 1 : Chkdsk has found issues with indexes and security descriptors and did not finish. Scheduling chkdsk to run again in read-only mode in 60 minutes. OS Type : 0 Schedule Script Parameter 1 : 10380010 Parameter 2 : 60 Parameter 3 : #MachineID# OS Type : 0 Execute Shell Command Parameter 1 : eventcreate /L System /T Error /SO ChkDsk /ID 999 /D "Chkdsk has found issues with indexes and security descriptors and did not finish. Scheduling chkdsk to run again in read-only mode in 60 minutes." Parameter 2 : 1 OS Type : 0 ELSE Execute Script Parameter 1 : Chkdsk Step3 (NOTE: Script reference is NOT imported. Correct manually in script editor. Parameter 2 : Parameter 3 : 0 OS Type : 0
Script Name: Chkdsk Step3 Script Description: This script checks the log for indications that check disk should be run against the drive with the /f parameter. IF Check Variable Parameter 1 : #chkdsklog# Contains :Windows found problems with the file system. THEN Get Variable Parameter 1 : 10 Parameter 2 : Parameter 3 : AgentTemp OS Type : 0 Get Variable Parameter 1 : 6 Parameter 2 : Parameter 3 : MachineID OS Type : 0 Get Variable Parameter 1 : 1 Parameter 2 : #AgentTemp#\chkdsklog.txt Parameter 3 : chkdsklog OS Type : 0 Send Email Parameter 1 : (alert/monitoring email address) Parameter 2 : #MachineID# - Chkdsk found problems with the filesystem. Please arrange for 'chkdsk /f' to be run. Parameter 3 : #chkdsklog# OS Type : 0 Delete File Parameter 1 : #AgentTemp#\chkdsklog.txt OS Type : 0 ELSE Get Variable Parameter 1 : 10 Parameter 2 : Parameter 3 : AgentTemp OS Type : 0 Write Script Log Entry Parameter 1 : Chkdsk found no errors in the filesystem. OS Type : 0 Delete File Parameter 1 : #AgentTemp#\chkdsklog.txt OS Type : 0