• This update of the script outputs 2 formatted columns in addition to the raw numbers:

    DECLARE @intDrive Integer,

    @strSQL Varchar(100);

    SET @intDrive = 97;

    DECLARE @Drives TABLE (

    Drive Char(1),

    Info Varchar(80));

    WHILE @intDrive <= 122

    BEGIN

    SET @strSQL = 'execute xp_cmdshell ''fsutil volume diskfree ' + CHAR(@intDrive) + ':''';

    INSERT @Drives(Info)

    EXEC (@strSQL);

    UPDATE @Drives

    SET Drive = CHAR(@intDrive)

    WHERE Drive IS NULL;

    SET @intDrive = @intDrive + 1;

    END;

    SELECT Drive,

    convert(varchar, cast((left(TotalBytes,len(TotalBytes)-2)) as money)/1000000000, 1) 'Total Space (GB)',

    convert(varchar, cast((left(FreeBytes,len(FreeBytes)-2)) as money)/1000000000, 1) 'Free Space (GB)',

    TotalBytes,

    FreeBytes

    FROM (SELECT Drive,

    SUM(CASE WHEN Info LIKE 'Total # of bytes : %' THEN CAST(REPLACE(SUBSTRING(Info, 32, 48), CHAR(13), '') AS Bigint) ELSE CAST(0 AS Bigint) END) TotalBytes,

    SUM(CASE WHEN Info LIKE 'Total # of free bytes : %' THEN CAST(REPLACE(SUBSTRING(Info, 32, 48), CHAR(13), '') AS Bigint) ELSE CAST(0 AS Bigint) END) FreeBytes,

    SUM(CASE WHEN Info LIKE 'Total # of avail free bytes : %' THEN CAST(REPLACE(SUBSTRING(Info, 32, 48), CHAR(13), '') AS Bigint) ELSE CAST(0 AS Bigint) END) AvailFreeBytes

    FROM (SELECT Drive, Info

    FROM @Drives

    WHERE Info LIKE 'Total # of %') useless_alias

    GROUP BY Drive) useless_alias_2

    ORDER BY Drive;

    412-977-3526 call/text