Submitted By: Trev Scott

Lists the free drive space on domain controllers.

Visual Basic
Edit|Remove
' Useage: cscript serverspace.vbs / >> log.txt


' header for results

WScript.Echo "//////////////////////////////////////////////////////////"
WSCript.Echo "//"
WSCript.Echo "//      Free Space on Domain Controller Drives"
WSCript.Echo "//"
WScript.Echo "//////////////////////////////////////////////////////////"
WSCript.Echo 


Dim DistinguishedName 
Dim rootDSE 

Set rootDSE = GetObject("LDAP://rootDSE")
DistinguishedName = rootDSE.Get("defaultNamingContext")

Set objOU = GetObject("LDAP://ou=Domain Controllers," & DistinguishedName)


	For Each strServer In objOU
   		WScript.Echo
   		WScript.Echo "------------------------------------------"
   		WScript.Echo "Server " & strServer.CN
   		WScript.Echo "------------------------------------------"


		Set objWMIService = GetObject("winmgmts:\\" & strServer.CN & "\root\CIMV2") 
		Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk",,48) 

			For Each objItem in colItems 
    				Wscript.Echo "Freespace on drive " & objItem.Name & " " & mid(objItem.Freespace/1024000000, 1, 4) & "GB"


			Next
	Next