CheckDisk SystemDrive (Server RDP detect)
Edit script line 1 for number of failures before email is sent and line 2 for the email addrsss to send to. Script runs a standard chkdsk, it then looks for failures if failures found it checks how many failures have been reported before. Then either sends email and schedules a chkdsk /f or schedules a chkdsk and adds failure to registry. Procedure will check for user logged in using qwinsta (windows server only, but will detect RDP sessions). If no user is logged in it will reboot to run chkdsk /f. Writes to script log if successful. Able to report by filtering script log for $ChkDsk$ $Audit$ $OOD$
A version of this script that does not use qwinsta.exe to detect if a user is logged in can be found here.