Error DataBase-One Place all Solutions Forums Blog Glossary    Contact Us
Search  
   
Browse by Category
Error DataBase-One Place all Solutions .: Operating Systems .: Windows Operating Systems .: Windows Scripts and Batch Files .: VBS Script To Send All AD Domain Controllers Disk Space Information To Excel

VBS Script To Send All AD Domain Controllers Disk Space Information To Excel

This VBS script will write all the Active Directory (AD) Domain Controllers local disk space information to excel for the local AD domain.

VBS Script:

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2

objExcel.Cells(1, 1).Value = "Server Name"
objExcel.Cells(1, 2).Value = "Drive Letter"
objExcel.Cells(1, 3).Value = "Total Space (GB)"
objExcel.Cells(1, 4).Value = "Free Space (GB)"

Set objDomain = GetObject("LDAP://RootDSE")
strDomain = objDomain.Get("DefaultNamingContext")
Set objOU = GetObject("LDAP://ou=Domain Controllers," & strDomain)
For Each strServer In objOU

Set objWMIService = GetObject("winmgmts:\\" & strServer.CN & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_LogicalDisk Where DriveType = 3")
For Each objItem in colItems

objExcel.Cells(intRow, 1).Value = strServer.Cn
objExcel.Cells(intRow, 2).Value = objItem.Name
objExcel.Cells(intRow, 3).Value = (FormatNumber(objItem.Size/ 1024^3, 1)) & " GB"
objExcel.Cells(intRow, 4).Value = (FormatNumber(objItem.Freespace/ 1024^3, 1)) & " GB"
intRow = intRow + 1
Next
Next

objExcel.Range("A1:D1").Select
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Range("A1:D1").Select
objExcel.Cells.EntireColumn.AutoFit

MsgBox "Done"


How helpful was this article to you?

Related Articles

article VB Script to GET Domain membership information
Set oResults=oSvc.ExecQuery _ ...

(No rating)  3-24-2008    Views: 190   
article VB Script to Send Email
  Dim SendMail Set SendMail =...

(No rating)  3-24-2008    Views: 149   
article How to Change the Amount of Disk Space Used by System Restore
The System Restore program created restore...

(No rating)  3-27-2008    Views: 148   

User Comments

Add Comment
No comments have been posted.