Disk space (including mounted drive) Check via SQL Server

In my previous article on Diskspace Check via SQLServer will find only physical logical drives that is attached to the system i.e the drive which you see under my computer. Ive used this script in one of my client machine and found that this script is not capable to check disk space for mounted drives. Hence Ive written an WMI script and SQL Script (like version 1) to fetch both physical disk & mounted disk space details. I hope this would help most of the DBAs to monitor their mounted voulmes where they have hosted their database files.

In the script below Ive just provide you the output of total disk space, free space details. You can modify the SQL Script further to suite for your requirement.

Version : 2

How to Use

  • Download both the scripts and save it to your local drive
  • In SQL Script you need to change the parameter @VBSPATH to the path where you have stored the WMI Script including the file name
  • Save the script
  • Use the modified SQL Script to know the disk details

Download SQL Script

Download WMI Script

To shown an example Ive mounted a drive to C:Mounted Drive folder and executed the script.

Sample Output

mounteddrive_v2


Posted

in

by

Comments

7 responses to “Disk space (including mounted drive) Check via SQL Server”

  1. Praveen avatar
    Praveen

    Hi Sagar, Your script is working great. Thanks ton

  2. senthilkumar avatar
    senthilkumar

    Hi Vidhi,
    If you ve given Ref Link in “Diskspace Check via SQLServer” it is easy and useful to go ur previous artcile.
    Otherwise It is working fine
    thanks

    1. VidhyaSagar avatar

      Link updated buddy

  3. Jawad avatar
    Jawad

    Hi VidhyaSagar,

    xp_cmdshell is disabled on my servers. Is there any option to run this script without the help of xp_cmdshell ?

    Regards
    Jawad

    1. VidhyaSagar avatar

      Yes its required. You can also try in SQLCMD mode from SSMS

  4. Craig Cartwright avatar
    Craig Cartwright

    I can run the script fine, but the I do not get any output (only the headers appear).

    1. VidhyaSagar avatar

      @Craig – This means the vbs script file doesnt returned any data. Did you changed the path for vbs script in sql script file? Are you running this in server or from your workstation?

Leave a Reply

Your email address will not be published. Required fields are marked *