Shavlik Script Catalog: Defragment Disk Drive

Version 5

    Author: Shavlik
    Category: Maintenance
    Inputs: Drive letters (or all), and analyze-only option
    Minimum ITScripts engine version required:  8.0.0.0
    Modifies the target machine: Yes
    Name: Defragment Disk Drive
    Outputs: Output from running Defrag on target machines

    Purpose: Defragment disk drive(s)

    Script Version: 1.0.0.33

    Target Type: Any

     

    Technical Description:

    This script allows and administrator to initiate a Diskdefrag on a target machine remotely.  The script will query the logical disks using WMI to determine what disks can be defragged on the target and passes in the command similar to the following example:

     

    "cmd /c Defrag.exe $volume /a 1>$fileName 2>&1"

     

    Possible OpsMon status includes:

    "Windows NT/2000 do not support command-line defrag"

    "Failed to enumerate logical disks"

    "None of selected drives found ($driveLetters)"

    "Volume $volume is is marked as dirty.  You must run chkdsk on the

    volume to correct any problems before you attempt to defragment it."

    "Defrag started on $volume (Analyze only)"

    "Defrag started on $volume (Analyze and fix)"

    "Defrag complete on $volume"

     

    Caveats:
    Windows NT/2000 do not support command-line defrag.