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:
    Modifies the target machine: Yes
    Name: Defragment Disk Drive
    Outputs: Output from running Defrag on target machines

    Purpose: Defragment disk drive(s)

    Script Version:

    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"


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