This VBS script will take a server or machine name form an input box and write the following disk drive information to an excel spreadsheet. System Name, Device ID, Description, File System, Volume Name, Disk Size (GB) and Free Space
VBS Script:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "SystemName"
objExcel.Cells(1, 2).Value = "DeviceID"
objExcel.Cells(1, 3).Value = "Description"
objExcel.Cells(1, 4).Value = "FileSystem"
objExcel.Cells(1, 5).Value = "VolumeName"
objExcel.Cells(1, 6).Value = "Disk Size (GB)"
objExcel.Cells(1, 7).Value = "FreeSpace"
strComputer = InputBox("Enter Server Name")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\Cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where DriveType = 3")
For Each objItem in colItems
objExcel.Cells(intRow, 1).Value = objItem.SystemName
objExcel.Cells(intRow, 2).Value = objItem.DeviceID
objExcel.Cells(intRow, 3).Value = objItem.Description
objExcel.Cells(intRow, 4).Value = objItem.FileSystem
objExcel.Cells(intRow, 5).Value = objItem.VolumeName
objExcel.Cells(intRow, 6).Value = Int(objItem.Size / 1048576 / 1024)
intFreeSpace = objItem.FreeSpace
intTotalSpace = objItem.Size
pctFreeSpace = intFreeSpace / intTotalSpace
objExcel.Cells(intRow, 7).Value = FormatPercent(pctFreeSpace)
intRow = intRow + 1
Next
objExcel.Range("A1:G1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
MsgBox "Done"
No Comments